Question: Which symbol is used to create multiple inheritance?
(a). Dollar symbol
(b). comma symbol
(c). Dot symbol
(d). A or b
(e).None of these
The answer of MCQs:
(b). comma symbol
Syntax of multiple inheritance in C++ OOP
1 2 3 4 5 | class C: public A, public B { } |
In this example, a comma is in between class A and class B.
C++ program in which comma symbol is used to create multiple inheritance?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include<iostream> using namespace std; class A { protected: int n1; }; class B { protected: int n2; }; class C : public A, public B { public: int total() { cout<<"Please enter the n1?"<<endl; cin>>n1; cout<<"Please enter the n2?"<<endl; cin>>n2; cout<<"sum="<<n1+n2<<endl; } }; int main() { C T4Tutorials_Object; T4Tutorials_Object.total(); } |