Page 209 - DCAP404 _Object Oriented Programming
P. 209
Object-oriented Programming
Notes void display 1 (void)
{
cout << “b1 = “ <<b1 << “\n”;
}
}
Class C: public B, public A
{
int p, q;
public c:
c (int a, float b, int c, int d): A(a), B(b)
{
p = c;
q = d;
cout << “constructor of c \n”;
}
void display 2 (void)
{
count << “p = “ << p << “\n”;
cout << “q = “ << q << “\n”;
}
}
main ( )
{
c obj (10, 20.57, 40, 70);
cout << “\n”;
obj . display ( );
obj . display 1( );
obj . display 2 ( );
}
The out of the above code would be as follows:
Constructor of B
Constructor of A
Constructor C
a1 = 10
b1 = 20.57
b = 40
q = 70
202 LOVELY PROFESSIONAL UNIVERSITY