| Introduction to OOP | Chapter 23: Object Interconnections : | next | previous | audio | real | text |
class SneekyModifier {
public:
void sneeky () {
// change my friends name
myFriend->name = "Lucy";
}
Person * myFriend;
};
|
class Person {
public:
Person () {
name = "Larry";
}
string name;
};
|
This is bad because it makes it difficult to understand a single class
in isolation.
Can be mitigated by always making your data areas private or protected,
and not exposing pointers to these areas.