I have this:
//Constructor
ApplicationConstructor::ApplicationConstructor(string constructorCode, char *constructorName, string constructorEmail){
int i = strlen(constructorName);
ConstructorName = new char[i+1];
strncpy(ConstructorName, constructorName, (i+1));
ConstructorCode = constructorCode;
ConstructorEmail = constructorEmail;
}
//Copy constructor
ApplicationConstructor::ApplicationConstructor(const ApplicationConstructor &applicationConstructor){
int i = strlen(applicationConstructor.ConstructorName);
ConstructorName = new char[i+1];
strncpy(ConstructorName, applicationConstructor.ConstructorName, (i+1));
ConstructorCode = applicationConstructor.ConstructorCode;
ConstructorEmail = applicationConstructor.ConstructorEmail;
}
ApplicationConstructor::~ApplicationConstructor(){
cout << "Destruct the object ApplicationConstructor: " << this-
>ConstructorName << endl;
delete[] this->ConstructorName;
}
//Show the Application Constructor Data Method
void ApplicationConstructor::showData(){
cout << " Code: " << this->ConstructorCode
<< " Name: " << this->ConstructorName
<< " Email: " << this->ConstructorEmail
<< endl;
}
And this:
int main(int argc, char** argv) {
ApplicationConstructor appConstructor1("3324",(char *)"Konstantinos Dimos", "konstantinos@uniwa.gr");
ApplicationConstructor appConstructor2("3332",(char *)"Maria Paulou", "nikos@uniwa.gr");
appConstructor2 = appConstructor1;
appConstructor2.showData();
}
And I get this when I run it:
Code: 3324 Name: Konstantinos Dimos Email: konstantinos@uniwa.gr
Destruct the object ApplicationConstructor: Konstantinos Dimos
Destruct the object ApplicationConstructor: h�
What are these letters h�? I have made many times the same code on other programms but now I can't understand what is that? Any suggestion?