// Simple example of C++ class with non-virtual // functions and no explicit use of "this" // CSE 333 lecture demo, 3/16. HP #include using namespace std; class Thing { public: Thing(int x) { this->x_ = x; } int getX() { return this->x_; } void setX(int x) { this->x_ = x; } private: int x_; }; int main() { Thing t1(17); Thing *t2 = new Thing(42); int n1 = t1.getX(); int n2 = t2->getX(); cout << "t1 x = " << n1 << ", t2 x = " << n2 << endl; t1.setX(333); cout << "t1 x = " << t1.getX() << endl; return 0; }