Skip to main content
GameDev.net gamedev.net
🔒 Locked

static operator overloads

Started by Yohomyth Jul 12, 2004 at 8:33 AM 1 replies 250+ views
Original Post
Yohomyth
Yohomyth
In VC6 I tried to overload an operator with a static function:
CMyClass &operator=(CMyClass &l, int &r)
{
    //...
}


...but it didn't work. I got an error message that said that operator overloads must be non-static. But I got the info on how to do static operator overloads from MSDN library. Is one of my products (VC6/MSDN Library) out of date?
------------------------------------------------------------"Many combilations elizagerth. I hope you see my particles." - Senor Cardgage
DigitalDelusion
DigitalDelusion
operator= must be a non static member, other operators can be freestanding
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
mackscynox
mackscynox
as far as i know the = operator must be defined with one parameter and the compilers (i didnot try) will generate errors with some operators such as (++pre , [] and also will generate error again if not define an argument in >> , << , == operators)

i mean the "static" error that occurs is because you try the binary operator with 3 arguments

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.