Memberpointer lässt sich nicht verändern, warum?
-
Hallo
Ich hab folgendes Problem und weiß nicht warum das nicht compelliert:
class XYZ { ... private: TType* m_poCache; }; XYZ::XYZ() { m_poCache = NULL; } void XYZ::DoSomething() { ... TType* poNew = new TType(); ... if(m_poCache) delete m_poCache; m_poCache = poNew; //here i get compiler error: error C2166: l-value specifies const object }Im konkreten Fall ist TType:
typedef std::vector<unsigned int> TPointIndeces; typedef std::pair<double, std::pair<double, TPointIndeces>> TLineCache;Also nirgends ein const object zu finden

-
oh, i found the error, my function "DoSomething" was declarated as const
-
Franz777 schrieb:
typedef std::vector<unsigned int> TPointIndeces; typedef std::pair<double, std::pair<double, TPointIndeces>> TLineCache;Wenn du kein C++0x hast musst du > > statt >> schreiben!
-
EOutOfResources schrieb:
Franz777 schrieb:
typedef std::vector<unsigned int> TPointIndeces; typedef std::pair<double, std::pair<double, TPointIndeces>> TLineCache;Wenn du kein C++0x hast musst du > > statt >> schreiben!
Wenn du es schon genau nimmst, musst du aber auch eingestehen, dass man C++0x nicht "haben" kann.
-
Das heißt declared und nicht declarated.