C++ Class Definition Integer class
#include <iostream> class Integer{//from w w w .ja v a 2 s.com private: int n; public: Integer(int m); int getValue() {return n;} void setValue(int m){ n = m; } void show(); }; Integer::Integer(int m) { n = m; std::cout << "Object created." << std::endl; } void Integer::show() { std::cout << "Value is " << n << std::endl; } int main() { std::cout << "Create i with the value 10." << std::endl; Integer i {10}; i.show(); std::cout << "Change value of i to 15." << std::endl; i.setValue(15); i.show(); k.show(); }