Overloaded functions

Nasza ocena:

Wyświetleń: 672
Komentarze: 0

Pobierz ten dokument za darmo

Podgląd dokumentu
Overloaded functions - strona 1 Overloaded functions - strona 2

Fragment notatki:

Overloaded functions  More than one function of the same name, … but different parameters  Type of result is irrelevant (may not be used to overload) … because the result may be ignored in the call int f(int, int); int f(int); int f(long);  Pointers to overloaded functions - the compiler has to know which one you mean // we assume prototypes from the previous slide int (*p)(long); //OK p=f; void *pf; pf=f; // ERROR!  Parameters of overloaded function must differ  Type returned is not considered during compilation, it is examined when function is called int f(int, int); int f(int); int f(long); // OK // int f(int); double f(int); ERROR int ff(int); int ff(double); // OK // ff(1L) ERROR! ambiguous // void *p=ff(1) ERROR! type ... zobacz całą notatkę

Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz