summaryrefslogtreecommitdiff
path: root/ccc/class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ccc/class.cc')
-rw-r--r--ccc/class.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/ccc/class.cc b/ccc/class.cc
new file mode 100644
index 0000000..b493b51
--- /dev/null
+++ b/ccc/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;
+}
+