Strona startowa Ludzie pragną czasami się rozstawać, żeby móc tęsknić, czekać i cieszyć się z powrotem.</td> </tr> <tr> <td colspan="2"> <input type="submit" name="Submit" value="Wyślij"> </td>...<input type="submit" name="Submit" value="Submit"> </form> </body> </html> Rozdział 4 – Operacje na...Output strstreamsOutput strstreams also allow you to provide your own storage; in this case it’s the place in memory the bytes are formatted into...In any case, you will need a binding schema that contains instructions for the schema compiler...A question mark (?) indicates that the preceding type, word, or group is optional...The questions which proved easiest in this part were 17, 19, 21 and 30 Part 3 ‘Key’ Word Transformations In 31, a number of candidates changed the prompt word...restriction on the representation type used; record structuresare allowed...on, along with the type and state of each replica...— and using the caller ID phone number in your search would result in us not finding the right user...W swoim klasycznym studium4 Berle i Means podkrelali, e to daleko posunite rozproszenie wasnoci kapitau akcyjnego doprowadzio do rozdziau wasnoci i kontroli...
 

Ludzie pragną czasami się rozstawać, żeby móc tęsknić, czekać i cieszyć się z powrotem.

In both C and C++, the declaration func(void); means an empty argument list. The void keyword means “nothing” in this case (it can also mean “no type” in the case of pointers, as you’ll see later in this chapter).
The other option for argument lists occurs when you don’t know how many arguments or
what type of arguments you will have; this is called a variable argument list. This “uncertain argument list” is represented by ellipses (... ). Defining a function with a variable argument list is significantly more complicated than defining a regular function. You can use a variable
argument list for a function that has a fixed set of arguments if (for some reason) you want to Chapter 1: Data Abstraction
92
disable the error checks of function prototyping. Because of this, you should restrict your use of variable argument lists to C, and avoid them in C++ (where, as you’ll learn, there are much better alternatives). Handling variable argument lists is described in the library section of your local C guide.
Function return values
A C++ function prototype must specify the return value type of the function (in C, if you
leave off the return value type it defaults to int). The return type specification precedes the function name. To specify that no value is returned, use the void keyword. This will generate an error if you try to return a value from the function. Here are some complete function
prototypes:
int f1(void); // Returns an int, takes no arguments
int f2(); // Like f1() in C++ but not in Standard C!
float f3(float, int, char, double); // Returns a float
void f4(void); // Takes no arguments, returns nothing
To return a value from a function, you use the return statement. return exits the function, back to the point right after the function call. If return has an argument, that argument becomes the return value of the function. If a function says that it will return a particular type, then each return statement must return that type. You can have more than one return statement in a function definition:
//: C03:Return.cpp
// Use of "return"
#include <iostream>
using namespace std;
char cfunc(int i) {
if(i == 0)
return 'a';
if(i == 1)
return 'g';
if(i == 5)
return 'z';
return 'c';
}
int main() {
cout << "type an integer: ";
int val;
cin >> val;
cout << cfunc(val) << endl;
} ///:~
Chapter 1: Data Abstraction
93
In cfunc( ), the first if that evaluates to true exits the function via the return statement.
Notice that a function declaration is not necessary because the function definition appears
before it is used in main( ), so the compiler knows about it from that function definition.
Using the C function library
All the functions in your local C function library are available while you are programming in C++. You should look hard at the function library before defining your own function – there’s a good chance that someone has already solved your problem for you, and probably given it a
lot more thought and debugging.
A word of caution, though: many compilers include a lot of extra functions that make life
even easier and are very tempting to use, but are not part of the Standard C library. If you are certain you will never want to move the application to another platform (and who is certain of that?), go ahead –use those functions and make your life easier. If you want your application to be portable, you should restrict yourself to Standard library functions. If you must perform platform-specific activities, try to isolate that code in one spot so it can easily be changed when porting to another platform. In C++, platform-specific activities are often encapsulated in a class, which is the ideal solution.
The formula for using a library function is as follows: first, find the function in your
programming reference (many programming references will index the function by category as
well as alphabetically). The description of the function should include a section that