# include <iostream># include <stdio.h>class a {public:a () :i ( { }virtual void f () { std::cout << "A::f () i = "&NBSP;<<&NBSP;I&NBSP;<<&NBSP;STD::ENDL;} int i;}; Class b : public a{public:b () :j () { }virtual void f () { std::cout << "B::f () j = " << j<< std::endl; }int j;}; Int main () {a *a = new a ();std::cout << "A *a = new a (); " << std::endl;std::cout << " a->i = " << a->i << std::endl; a b;std::cout << "a b; " &NBSP;<<&NBSP;STD::ENDL;STD:: cout << "A&NBSP;&NBSP;C;&NBSP;&NBSP;&NBSP; " << std::endl; a c;std::cout << "b.i = " &NBSP;<<&NBSP;B.I&NBSP;<<&NBSP;STD:: endl << std::endl;; int* p = (int*) &b;int* p2 = (int*) &a;int* p3 = (int*) &c;int* p4 = (int*) *p;std::cout << "int* p4 = (int*) *p; the *p4 is " << *p4 << std::endl; std::cout << "int* p4 = (int*) *p; the p4 is " << p4 << std::endl;std::cout << " int* p3 = (int*) &c; the *p3 is " << *p3 << std::endl;std::cout << "int* p = (int*) &b; the *p is " << *p << std::endl;std::cout << "*p2 = " < < *p2 << std::endl;std::cout << "A is a point : a* a = new a (); the sizeof (A) is " << sizeof (a) << std::endl;std::cout << " b is a object : A b; the sizeof (b) is " << sizeof (b) << std::endl<<std::endl;p++;p 2++;std::cout << "* (p++) = " < < *p << std::endl;std::cout << "p++ = " << p << std::endl;std::cout << " * (p2++) = " << *p2 << std::endl;std::cout << "p2++ = " << p2 << std::endl;/***********************************************************/a d; b e; A* pa = &e;pa->f (); Char cc = getchar (); return 0;}
Code Run Result:
C + + fundamentals (i)