IN C++, IN C++, IN C++ Write the A and B classes, the properties of which...

60.1K

Verified Solution

Question

Programming

IN C++, IN C++, IN C++

Write the A and B classes, the properties of which will producethe expected output with the test code provided, and thecharacteristics of which are specified below. Note the types ofpointers used in the test code.
Methods of class A:
- void hi () - Prints “Hi A” on the screen.
- void selam() - Prints \"Selam A\" on the screen.
Class B must inherit class A. Class methods should be written sothat access levels can produce the desired output in the test codeprovided.

Test code:

int main() {
A* ptrA1 = new A{};
A* ptrB1 = new B{};
B* ptrB2 = new B{};
ptrA1->selam();
ptrA1->hi();
ptrB1->selam();
ptrB1->hi();
ptrB2->selam();
ptrB2->hi();
return 0;
}

Expected output:

Selam A
Hi A
Selam A
Hi B
Selam B
Hi B

Answer & Explanation Solved by verified expert
4.2 Ratings (812 Votes)
C CODE TO COPYprecompiled used headersincludeusing    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students