123456789101112131415161718192021222324252627282930313233
#include <iostream> using namespace std; class Cat { public: virtual void speak() { cout << "meow" << endl; } }; class Lion : public Cat { public: void speak() { cout << "roar" << endl; } }; int main() { Lion l; Cat c = l; Cat* cPtr = &l; Cat& cRef = l; l.speak(); c.speak(); cPtr->speak(); cRef.speak(); return 0; }
123456789
class A { friend double compute (A& data) }; class B { friend class A; };