Lab 11 - Coupling, Cohesion and Visibility
Example Code from Lecture
Access and visibility - slide 22
#include <iostream> using namespace std; class Sneaky { private: int safe; public: Sneaky() { safe = 10; }; int &sorry() { return safe; } void print() { cout << safe << endl; }; }; int main() { Sneaky x; x.sorry() = 1; x.print(); int y = x.sorry(); y = 2; x.print(); int &z = x.sorry(); z = 3; x.print(); }
Exercises
page revision: 0, last edited: 22 Nov 2009 11:33