Topic: April 1 Suggestion - enemy classes
Author: miket@world.std.com (Michael Trachtman)
Date: Tue, 22 Mar 1994 04:31:03 GMT Raw View
Another suggestion for "improving" c++.
C++ currently has a "friend" declaration for allowing other
classes and functions to access private members.
I suggest adding an "enemy" keyword. This keyword would allow
one class to declare other classes and functions as "enemies".
An enemy class or function may not access any part of the class
who is declaring the enemy. This includes public parts.
An example will illustrate.
class X;
class Y;
class X {
enemey class Y;
void do_something() { cout << "HI there \n"; }
};
class Y {
public:
void busy_work(X& x) {
while (some_condition())
x.do_something(); // error, Y is an enemy of X.
}
}
void
main() {
X x;
Y y;
y.busy_work(x);
}
Michael Trachtman
------------------------------------------
P.s. before you flame me for this, please read the subject of this postings.