F
fungus
I define this class:
class foo {
std::vector<int>data;
public:
int operator[](int n) {
return data[n];
}
int operator[](int n) const {
return data[n];
}
};
Now in my program I do:
foo myFoo;
int x = myFoo[123];
....
Should the const version of foo:perator[] be called?
I think it should, but my compiler disagrees with me.
What's the correct behavior? Why...?
--
<\___/>
/ O O \
\_____/ FTB.
http://www.topaz3d.com/ - New 3D editor!
class foo {
std::vector<int>data;
public:
int operator[](int n) {
return data[n];
}
int operator[](int n) const {
return data[n];
}
};
Now in my program I do:
foo myFoo;
int x = myFoo[123];
....
Should the const version of foo:perator[] be called?
I think it should, but my compiler disagrees with me.
What's the correct behavior? Why...?
--
<\___/>
/ O O \
\_____/ FTB.
http://www.topaz3d.com/ - New 3D editor!