.


:




:

































 

 

 

 





. :

void f(int a) { /* */} //

void (*pf) (int); //

...

pf = &f; //

pf(10); // f pf

, . , (typedef):

 

# include <iostream.h>

typedef void (*pf) (int); // PF

// f1 PF

void f1(PF pf) {

pf(5); // ,

}

void f(int i) { cout << i; }

int main () {

f1(f);

return 0;

}

, . . , , . , :

int f (int a, int b=0);

void f1 (int, int = 0, char*=0);

...

f(100);

f(a,1);

...

f1(a); f1(a,10); f1(a, 10, "Ivan");

, , , . , .

, , . . .

. , :

int max (int, int);

char * max (char*, char*);

int max (int, char*);

int max (char*, int);

// -

void f(int a, int b, char *c, char *d) {

cout<<max(a,b)<<max(c,d)<<max(a,c)<<max(c,b);

}

max . , , bool char int, float double .. , int double void*. , , . , .

:

- ;

- -;

- .

. :

# include <iostream.h>

float f(float i) {

cout << "fuction float f(float i)"<<endl; // endl // -

return i;

}

doudle f(double i) {

cout << "fuction double f(double i)"<<endl;

return i*2;

}

int main () {

float x = 10.09;

double y = 10.09;

cout << f(x) << endl; // f(float)

cout << f(y) << endl; // f(double)

/* cout << f(10) << endl; − : 10: float double? */

return 0;

}

10.

-: Int f(int a, int b), int f(int a, int &b), , . , , , .

. :

# nclude <iostream.h>

int f(int a) { return a;}

int f(int a, int b =1) {return a*b;}

int main () {

cout << f(10,2); // f(int, int)

// cout << f(10); - : - f(int) f(int, int)?

return 0;

}





:


: 2016-10-06; !; : 724 |


:

:

, , .
==> ...

1786 - | 1467 -


© 2015-2024 lektsii.org - -

: 0.009 .