To tylko jedna z 4 stron tej notatki. Zaloguj się aby zobaczyć ten dokument.
Zobacz
całą notatkę
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)