#include<iostream>
const int size = 2;
using namespace std;
class Human
{
protected:
string name;
public:
Human(string);
string setName(string);
string getName();
};
int main()
{
Human *p = new Human[2] ={Human("BBBB"),Human("CCCC")}
return 0;
}
Human::Human(string name)
{
this -> name = name;
cout << " The Object is now created ! " << endl;
}
string Human::setName( string name)
{
name = name;
}
string Human::getName()
{
return name;
}
Hi
I want use dynamic array when create a object , but when use a dynamic array compiler return error . what is my problem ???
What is your error? Although it may seem obvious and easy enough for us to copy and paste the code you provided, and at first that's exactly what I did, we don't often do this and I my self have stopped for a couple of reasons. Please let us know what your compiler is complaining about and maybe what compiler you are using.