C
Chris Mantoulidis
Forgive me if I'm wrong but I think there is something like an extra
member scope in classes.
for example:
class abc {
ostream & operator << (ostream &, const abc &);
istream & operator >> (istream &, abc &);
private:
//...
public:
//...
};
-------
Now when I implement operator << and >>, note that I mustn't say they
are part of abc...
ostream & operator << (ostream & os, const abc & ABC) {
//but not ostream & abc:perator << (.............) {
//.......
}
-------
So when putting members in the part of the class with no specified
scope, they are not exactly part of the class anymore?
When I try to put those (<< and >>) in public scope, it won't work;
plus it wouldn't make sence to say (in the "complicated form")
ABC.operator << (cout, ABC);...
So am I right? Is there something like an extra scope? Wouldn't it be
the same if I just defined ostream & operator << (ostream &, const abc
& ABC); outside the class? Isn't it just overloading?
Of course all of the above might be wrong, but it is worth asking.
TIA,
cmad
member scope in classes.
for example:
class abc {
ostream & operator << (ostream &, const abc &);
istream & operator >> (istream &, abc &);
private:
//...
public:
//...
};
-------
Now when I implement operator << and >>, note that I mustn't say they
are part of abc...
ostream & operator << (ostream & os, const abc & ABC) {
//but not ostream & abc:perator << (.............) {
//.......
}
-------
So when putting members in the part of the class with no specified
scope, they are not exactly part of the class anymore?
When I try to put those (<< and >>) in public scope, it won't work;
plus it wouldn't make sence to say (in the "complicated form")
ABC.operator << (cout, ABC);...
So am I right? Is there something like an extra scope? Wouldn't it be
the same if I just defined ostream & operator << (ostream &, const abc
& ABC); outside the class? Isn't it just overloading?
Of course all of the above might be wrong, but it is worth asking.
TIA,
cmad