summaryrefslogtreecommitdiff
path: root/c,cc/class.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-15 03:50:12 +0200
committerPatrick Simianer <p@simianer.de>2014-06-15 03:50:12 +0200
commit258e1b92ebbfdebefabc120969ab87c3d8b75c3d (patch)
treeef4ab11fe0bf9d720cea23b35711358a8465feeb /c,cc/class.cc
parentcf3a29feb5887344b6633ead1b4b6d5657a15a4b (diff)
old c,cc examples
Diffstat (limited to 'c,cc/class.cc')
-rw-r--r--c,cc/class.cc31
1 files changed, 31 insertions, 0 deletions
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 <iostream>
+
+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;
+}
+