Here is the class
class Email{
private:
char to[100];
char from[100];
char subject[200];
char body[1000];
public:
Email();
Email(char *za,char *od,char *tema, char *telo){
strcpy(to,za);
strcpy(from,od);
strcpy(subject,tema);
strcpy(body,telo);
}
~Email();
void setTo(char *to) {strcpy(this->to,to);}
void setFrom(char *from) {strcpy(this->from,from);}
void setSubject(char *subject) {strcpy(this->subject,subject);}
void setBody (char *body) {strcpy(this->body,body);}
char* getTo () {return to;}
char* getFrom () {return from;}
char* getSubject () {return subject;}
char* getBody () {return body;}
void print () {
cout<<"To: "<<to<<endl<<"From: "<<from<<endl<<"Subject: "<<subject<<endl<<body;
}
};
and as you can see it includes a destructor. The rest of the program is just one function and main.
int checkEmail(char *p){
int n=0,i=0;
while(p[i]!='\0')
{if(p[i]=='@')
n++;
i++;}
if(n==1)
return 1;
else return 0;
}
int main()
{
char od[100],za[100],tema[200],telo[1000];
cout<<"Za: ";
cin>>za;
if(checkEmail(za)){
cout<<"Od: ";
cin>>od;
cout<<"Tema: ";
cin>>tema;
cout<<"Poraka: ";
cin>>telo;
Email o(od,za,tema,telo);
cout<<"Isprateno: ";
o.print();
}
else cout<<"Pogresna adresa!";
}
It gives an error
- obj\Debug\main.o||In function `main':|
- C:\Users\Stefan\Desktop\EMail\main.cpp|58|undefined reference to `Email::~Email()'|
- C:\Users\Stefan\Desktop\EMail\main.cpp|58|undefined reference to `Email::~Email()'|
- ||=== Build finished: 2 errors, 0 warnings (0 minutes, 1 seconds) ===|
in the line containing o.print(); So what is it? Also can sb. tell me how to highlight some lines in my code?