Defining methods

Nasza ocena:

3
Wyświetleń: 707
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Defining methods - strona 1 Defining methods - strona 2 Defining methods - strona 3

Fragment notatki:

Defining methods  Inside class declaration class person { … void input() { cinageFNameLName; } // semicolon not required … };  a method defined inside a class declaration is inline by default  outside of the class: - use the scope operator - by default, such method is not inline void person :: set(int age, char *pFN, char *pLN) { person::age=age; // scope operator since local argument „age” // is visible, not person::age strcpy(FName, pFN); strcpy(LName, pLN); }  making the method inline: inline void person::output() { couti; // correct! Even if declaration of ”i” is below output(); // as above } void output(); int i; };  Outside of a class: - methods, class members must be specified either by class name, or by object name int test() { A a; int j=sizeof(A::i); void (A::*p)( )=&A::input; a.i=3; // i is public in A } ... zobacz całą notatkę

Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz