Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. В следующем примере отметьте, что напечатает данная программа:
  2. class A {
  3.    public:
  4.       void f() { cout<<”A::f<<endl; }
  5.       virtual void g() {cout<<”A::g<<endl;}
  6. };
  7. class B: public A {
  8.    public:
  9.       void f() { cout<<”B::f<<endl; }
  10.       virtual void g() {cout<<”B::g<<endl;}
  11. };
  12. int main() {
  13.     A a = B();
  14.     a.f();
  15.     a.g();
  16.     B b;
  17.     A &ra = b;
  18.     ra.f();
  19.     ra.g();
  20.     A *pa = new B();
  21.     pa->f();
  22.     pa->g();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement