Advertisement

A little c++ question

Started by November 12, 2000 05:38 AM
0 comments, last by Shaigan 24 years, 1 month ago
Hello guys. I have a little question. When I make en object and I overload an operator. How can get access to it without using ->operator ? For exemple if have an object like : class cTest { public: cTest() { i = 0; } cTest& operator =(int n) { i = n; return *this; } private: int i; }; after if I do : cTest Test1; Test1 = 10; Ok, it''s all right. It work fine. But if I do : cTest *Test2; Test2 = new cTest; Test2 = 10; don''t work And I must doing Test2->operator =(10); Is there another way to access to overloaded operators with a pointer ? Thanks for answers
Thomas DecroyèreCheck out my blog at: http://thomas.decroyere.be
no it won''t work, just like it won''t work if you have
float *f;f = 1.0f 


the way to do it is to use the at address operator or whatever it''s called... this one: *

*Test2 = 10;
[email=ehremo@hotmail.com][/email]

This topic is closed to new replies.

Advertisement