I have tried this:
int n;
cin >> n;
int * pn = new int[n];
Then I can use the array lik this: pn[i] = ...
But I would like to organize something of the kind with my own class:
class MyString
{
char* m_pStr;
public:
MyString(const char* pStr){
this->CreateArray(pStr);
strcpy(m_pStr, pStr);
}
}
void main(){
int N;
cout << "Iinput N: ";
cin >> N;
MyString * ar = new MyString[N];
char tmp[100];
for (int i = 0; i < 4; i++){
cout <<"Input the string for the Mystring " << i + 1 << " ";
cin >> tmp;
ar[i] = MyString(tmp);
}
}
I get: error C2512: 'MyString' : no appropriate default constructor available.