TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: FERNANDO ARIEL GONT
from: KURT KUZBA
date: 1997-07-25 14:17:00
subject: I want to learn C++

FA>   /*WHY IS IT A DEFINITION? */
FA>   /* WHY ISN'T IT A DECLARATION & DEFINITION? */
   I think I see wherein lies the confusion. :)
   This little text file might be useful. The exception,
   naturally, is that in C++, you may define or declare at any
   point in your code, and prototypes are REQUIRED in C++
   where C will assume an integer return type.
   Also, C++ allows the same function name to be used with
   different arguments, allowing an overloading of function
   names, and sometimes creating hilarious confusion. :)
   When you DEFINE something, you create an instance of it and
   commit your resources to it. When you DECLARE something, you
   only give the general specifications for it and do not commit
   any of your system resources to it.
   Politicians declare, and Statesmen define. ;)
   ***   CREATING FUNCTIONS AND PROTOTYPES IN C   ***
To create new functions in C, you only need to write them.
They consist of two parts.
1.  a prototype
2.  a codeblock
A prototype defines the function and its parameters.
It consists of a return data type, a function name, and the
arguments expected by the function.
int func(int variable)
{
   /*  code block  */
   return int_value;
}
A prototype for the function must appear in the code prior to any
usage of the function by the code.  The function itself may appear
prior to any call to itself, or a separate prototype may exist
apart from the actual prototype which accompanies the code block.
This prototype does not require variable names for arguments, but
allows them. Only variable types are actually required here.
These prototypes take a form similar to other variable declaration
statements, and are, indeed, such. They even require a semi-colon.
They define a pointer to the function.
int func(int);
These pototypes must match the ones accompanying the function, as
far as return variable type, function name, and argument variable
type are concerned. These prototypes may appear outside of any
functions, allowing all subsequent code to access the function
thus prototyped, or they may be placed only in those functions
by which the given function is to be called.
In such cases, they may only appear at the beginning of a code
block, following the same rules as other variable types.
The code block may be whatever is necessary to implement the
purpose of the function, but must return a variable consistant
with the return value defined in the prototype.
Where no return values or arguments are required, a variable
type void should be used.
void func(void)
{
   /*  code block  */
}
Prototypes for the standard libraries are contained in the .H
files for those libraries. They are grouped by function and
utility. The string handling functions being prototyped in the
 file, etc...
   ***   end   CREATING FUNCTIONS AND PROTOTYPES IN C   ***
> ] When I bend my fingers backward, I hear Satanic messages....
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.