Q.1 what is the output of following program?

#include <iostream>
using namespace std;
class  A
{
      public:
      A()
        {       cout<<"Constructing  A"<<endl;
        }
        ~A()
        {       cout<<"Destructing  A"<<endl;
        }
};
class B : public  A
{       
          public:
          B()
          {
            cout<<"Constructing B"<<endl;
          }
        ~B()
        {cout<<"Destructing B"<<endl;
        }
};
int main()
{
         A *b=new B;
         delete b;
}
how is its output as:

constructing A
constructing B
destructing B
??


Q2. Determine output.
class  A
{       int a;
      public:
     virtual void f()
        {
        }
};
class B : private  A
{       int b;
          public:
        void f()
        {
        }
};
int main()
{
         cout<<sizeof(A)<<endl;
        cout<<sizeof(B)<<endl;
}
its output is:
 8    12

virtual functions do occupy 4 bytes ?? how??

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to