From 258e1b92ebbfdebefabc120969ab87c3d8b75c3d Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sun, 15 Jun 2014 03:50:12 +0200 Subject: old c,cc examples --- c,cc/class.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 c,cc/class.cc (limited to 'c,cc/class.cc') diff --git a/c,cc/class.cc b/c,cc/class.cc new file mode 100644 index 0000000..b493b51 --- /dev/null +++ b/c,cc/class.cc @@ -0,0 +1,31 @@ +#include + +using namespace std; + + +class A { + public: + A(int a):_a(a) {} + int geta() { + return _a; + } + static int _b; + private: + int _a; +}; + +int A::_b = 0; + +int main(void){ + A a(2); + A *b = new A(2); + cout << b->geta() << endl; + cout << b->_b << endl; + cout << a._b << endl; + A::_b = 42; + cout << b->geta() << endl; + cout << b->_b << endl; + cout << a._b << endl; + return 0; +} + -- cgit v1.2.3