Saturday, September 15, 2007

C++ Learning 3

A const reference can only call const member function.


void f(const Car& b) {


    b.GetName();   // ok


    b.StartEngine();// compile error


}


 


class Car {


    const char* GetName() const; // const member function


    void StartEngine();


}

0 Comments:

Post a Comment

<< Home