Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 VAX 124x: operator troubles
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Uniwares
Tomato Guru

Portugal
2322 Posts

Posted - Aug 09 2004 :  2:19:59 PM  Show Profile
Having a custom variant class, VAX messes with my operators.
1) VAX does not like operators with spaces like "operator unsigned int()". The HCB shows them as "operator unsignedint"
2) I see all my operators twice. Once as "operator xzy" and as " operator xzy" (note the space in front). I have definition and implementation in the same file, but separated, so that the definition is not also the implementation.
The tooltip in the HCB for these two shows "inline myvariant :: operator bool" for the proper operator and just "bool" for the one with the space in front. Both bring me to the same location anyway.
3) I still have destructors shown as operators like "operator ~myvariant()"

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Aug 24 2004 :  5:20:05 PM  Show Profile
i think points 2 and 3 are covered by case=209 from:
http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=903

for point 1, i have defined the test class:
class feline_test
{
public:
    feline_test();
    ~feline_test();
    operator unsigned int();

protected:
    int m_nCount;
};

and i am getting " operator unsignedint" in the HCB. there is a leading space in the HCB, and it looks like two spaces between operator and unsignedint.

also, when defining the function, i got as far as:
feline_test::ope|

when i got the suggestion listbox "operator unsignedint" so this confusion spreads beyond just the HCB.

case=234

what is this function? it looks like you are overloading the cast operator, but i am not certain. the code wont compile unless the function returns something, but it has no return type before the word "operator".

some of your bugs are an education in advanced C++

zen is the art of being at one with the two'ness
Go to Top of Page

Uniwares
Tomato Guru

Portugal
2322 Posts

Posted - Aug 24 2004 :  5:39:07 PM  Show Profile
Point 3 is not explicitly covered, but I assume good will

As for the operators - simple. Yes its basically defining a cast.
class one
{
public:
 operator unsigned int() { return 1; }
 operator LPCSTR()       { return "1"; }
 operator char()         { int i =3; return "aaa1bbb"[i]; }
};
since these are cast operator, the return type is the name. Very useful for wrapper classes or things like VARIANT classes. A funny usage of string pointers you can see in the char operator. Yes, that works.

You can use the cast operators for ANY type, builtin or your own. Have a look at the VARIANT class that comes with VC. It defines lots of operators like that.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Aug 24 2004 :  6:25:19 PM  Show Profile
i explicitly listed operator dtor in the case, so i will keep an eye on this when it gets fixed

i have encountered a Qt variant class, but it is full of accessors line:
int QVariant::toInt() const

i recall being very confused the first time i saw something like your char operator, but i have seen it put to good use now and then.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000