regarding over loading of operators

why the operators like =()[] must surely be the member functions?

if time permits pls explain me with some code

with regards,
vishnu
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
Topic archived. No new replies allowed.