c++ - operator= override not being used -
this question has answer here:
i have assignment:
main.cpp
polygon &q = polygonlist->top(); polygon p = q;
i want use operator override deep copy.
polygon.cpp
polygon& polygon::operator=(const polygon &obj) { // deep copy here return *this; }
polygon.hpp
public: polygon& polygon::operator=(const polygon &obj);
any idea why not hitting overide?
edit know not because debugger isn't breaking on return of override
you initializing p
using copy constructor.
instead of polygon p = q;
, try:
polygon p; p = q;
Comments
Post a Comment