c++ - Unresolved Externals between functions -


i'm getting unresolved external error can't figure out what's causing it.

error lnk2019: unresolved external symbol "public: __thiscall abc::abc(class abc const &)" (??0abc@@qae@abv0@@z) referenced in function "public: __thiscall hasdma::hasdma(class hasdma const &)" (??0hasdma@@qae@abv0@@z) 

1>c:\users\matt\documents\visual studio 2010\projects\gsp_125_lab5\debug\gsp_125_lab5.exe : fatal error lnk1120: 1 unresolved externals

the program runs when delete block of code:

hasdma::hasdma(const hasdma & hs) : abc(hs) {     style = new char[std::strlen(hs.style) + 1];     std::strcpy(style, hs.style); } 

but don't know part of being referenced elsewhere.

here abc header , hasdma header.

class abc { private:     enum {max = 35};     char label[max];     int rating; protected:     const char * label() const {return label;}     int rating() const {return rating;} public:     abc(const char * l = "null", int r = 0);     abc(const abc & rs);     virtual ~abc() {};     virtual abc & operator*()  { return *this; }     abc & operator=(const abc & rs);     virtual void view() const = 0;     friend std::ostream & operator<<(std::ostream & os, const abc & rs); };   class hasdma :public abc { private:     char * style; public:     hasdma(const char * s = "none", const char * l = "null",               int r = 0);     hasdma(const char * s, const abc & rs);     hasdma(const hasdma & hs);     ~hasdma(){};     hasdma & operator=(const hasdma & rs);     virtual void view() const; }; 

these 2 abc methods have:

abc::abc(const char *l, int r) {     std::strcpy(label, l);     label[max - 1] = '\0';     rating = r; }  abc & abc::operator=(const abc & rs) {     if (this == &rs)         return *this;      strcpy(label, rs.label);      return *this; } 

if helps these rest of hasdma methods:

hasdma::hasdma(const char *s, const char *l, int r) : abc (l, r) {     std::strcpy(style, s); }  hasdma::hasdma(const char *s, const abc & rs) {     std::strcpy(style, s); }  void hasdma::view() const {     cout << "record label: " << label() << endl;     cout << "rating: " << rating() << endl;     cout << "style: " << style << endl;  }  hasdma & hasdma::operator=(const hasdma & hs) {     if (this == &hs)         return *this;      abc::operator=(hs);     style = new char[std::strlen(hs.style) +1];     std::strcpy(style, hs.style);      return *this; } 

you have declared abc copy constructor, haven't defined it.

abc(const abc & rs); // declaration.  

you need provide definition, or remove declaration.

you simplify class using std::string instead of char array. wouldn't need provide assignment operator, copy constructor or destructor.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -