class - Undefined reference to destructor error in c++? -


here 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 can see includes destructor. rest of program 1 function , 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 error

  1. obj\debug\main.o||in function `main':|
  2. c:\users\stefan\desktop\email\main.cpp|58|undefined reference `email::~email()'|
  3. c:\users\stefan\desktop\email\main.cpp|58|undefined reference `email::~email()'|
  4. ||=== build finished: 2 errors, 0 warnings (0 minutes, 1 seconds) ===|

in line containing o.print(); it? can sb. tell me how highlight lines in code?

you're declaring destructor;

~email(); 

...but not defining body it. maybe mean;

~email() { } 

...or leave out if has no functionality?

(you're missing body declaration default constructor)


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)