ptg
May 19th, 2008, 10:48 PM
im working on a toy hierarchy but im getting a linkage error
error LNK2019: unresolved external symbol "public: __thiscall StuffedToy::StuffedToy(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double)" (??0StuffedToy@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0N@Z) referenced in function _main
fatal error LNK1120: 1 unresolved externals
i dont know why im getting this can anyone help?
#include<iostream>
#include <string>
using namespace std;
class Toy{
public:
Toy(const string &,double=0.0);
void setName(const string &);
string getName()const;
void setID(double);
double getID()const;
virtual void print() const;
};
class StuffedToy : public Toy{
public:
StuffedToy(const string&,const string&,double=0.0);
void setColor(const string &);
string getColor()const;
virtual void print() const;
};
int main(){
StuffedToy stuffedToy("bear","brown",123);
StuffedToy *stuffedToyPtr = 0;
stuffedToyPtr = &stuffedToy;
cout<<"dynamic binding: ";
stuffedToyPtr->print();
cout<<endl;
return 0;
}
error LNK2019: unresolved external symbol "public: __thiscall StuffedToy::StuffedToy(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double)" (??0StuffedToy@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0N@Z) referenced in function _main
fatal error LNK1120: 1 unresolved externals
i dont know why im getting this can anyone help?
#include<iostream>
#include <string>
using namespace std;
class Toy{
public:
Toy(const string &,double=0.0);
void setName(const string &);
string getName()const;
void setID(double);
double getID()const;
virtual void print() const;
};
class StuffedToy : public Toy{
public:
StuffedToy(const string&,const string&,double=0.0);
void setColor(const string &);
string getColor()const;
virtual void print() const;
};
int main(){
StuffedToy stuffedToy("bear","brown",123);
StuffedToy *stuffedToyPtr = 0;
stuffedToyPtr = &stuffedToy;
cout<<"dynamic binding: ";
stuffedToyPtr->print();
cout<<endl;
return 0;
}