Daniel Duffy
C++ author, trainer
- Joined
- 10/4/07
- Messages
- 10,335
- Points
- 648
Thank you APalley @APalley, I made a silly mistake to forget to write destructor lol..
After adding destructor, I still got one link error:
1>Shape.obj : error LNK2005: "public: class YC::CAD::Shape & __thiscall YC::CAD::Shape::operator=(class YC::CAD::Shape const &)" (??4Shape@CAD@YC@@QAEAAV012@ABV012@@Z) already defined in Point.obj
1>C:\Users\Danielle\Documents\Visual Studio 2010\Projects\Level 5\3.4-Exercise2\Debug\3.4-Exercise2.exe : fatal error LNK1169: one or more multiply defined symbols found
Below is my code for operator = in shape and point:
Code:Shape& Shape::operator=(const Shape& source) {//Assignment operator. cout<<"Shape assignment operator is called."<<endl; if (this == &source) return *this; this->m_id = source.m_id; return *this; }
Code:Point& Point::operator = (const Point& source) {//Print out text in assignment operator. cout<<"Point assignment operator called."<<endl; if (this==&source) return *this; Shape::operator=(source); this->m_x = source.m_x; this->m_y = source.m_y; return *this; }
Thanks!
one or more multiply defined symbols found