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
in the line containing o.print(); So what is it? Also can sb. tell me how to highlight some lines in my code?
You're declaring a destructor;
~Email();
...but not defining a body for it. Maybe you mean;
~Email() { }
...or to just leave it out if it has no functionality?
(You're also missing a body declaration for your default constructor)
You have to define your destructor, not just declare it. There is no visible implementation. Do something like this:
~Email() {
//Whatever you want your destructor to take care of
}
If you don't want to do anything with your destructor, then just don't even declare it. Also make sure you do the same thing for your constructor. It looks like you may have the same problem with it too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With