Write a class that contains an attribute name, a function to input, and a function to display name, create a array of pointers in which each elements refers to an object of the class using polymorphism
Answers
Answered by
0
Answer:
tjstdjll4edho94gkli7
Explanation:
titdjlo6dnlo6ednki
Answered by
0
Answer:
#include<iostream>
using namespace std;
class person
{
private:
char name[50];
public:
void get()
{
cout<<"Enter name";
cin>>name;
}
void show()
{
cout<<"name is"<<name<<endl;
}
};
int main()
{
person*ptr[5];
int i;
for(i=0;i<5;i++)
{
ptr[i]=new person;
ptr[i]->get();
}
for(i=0;i<5;i++)
{
ptr[i]->show();
}
return 0;
}
Similar questions
English,
3 months ago
Math,
3 months ago
Political Science,
7 months ago
English,
7 months ago
English,
11 months ago
Social Sciences,
11 months ago
Math,
11 months ago