regarding over loading of operators

Oct 20, 2014 at 4:43pm
why the operators like =()[] must surely be the member functions?

if time permits pls explain me with some code

with regards,
vishnu
Oct 20, 2014 at 4:53pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class foo
{
    foo(int) {} //Implicit conversion enabled constructor
}

foo& operator=(foo&, const foo&)
{} //Imagine that it is possible

int main
{
    foo x;
    5 = foo;
    //5 gets converted to foo, assigment takes place and.... What?
    //Does converted temporary just disappear?
    //Or there would miraclously happens to be a foo obkect instead of integer 5?
    //Even better possibilities:
    //5()
    // 5[]
}
Last edited on Oct 20, 2014 at 4:54pm
Topic archived. No new replies allowed.