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