Cpp 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2.a << "\n"; cout<<" s1.b -> " << s1.b << "\t s2.b -> " << s2.b <<"\n\n"; s1.a=100; cout<<" s1.a => " << s1.a << "\t"; cout<<" s2.a => " << s2.a <<"\n\n"; s1.b=200; cout<<" s1.b => " << s1.b << "\t"; cout<<" s2.b => " << s2.b << endl; } - 30 - [실습하기 9-9] 정적 멤버함수 정의하기 [예제 9-9] 9_9.cpp 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 #include<iostream> using namespace std; class StaticTest{ private: static int a; int b; public: StaticTest(); static void SetA(int new_a); static int GetA(); }; int StaticTest::a=10; StaticTest::StaticTest() { b=20; } - 31 - IT COOKBOOK [실습하기 9-9] 정적 멤버함수 정의하기 [예제 9-9] 9_9.cpp 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 void StaticTest::SetA(int new_a){ a = new_a; } int StaticTest::GetA(){ return a; } void main() { //cout<<" StaticTest.a => " << StaticTest.a << "\n\n"; cout<<" StaticTest::GetA() => " << StaticTest::GetA() << "\n\n"; StaticTest s1, s2; s1.SetA(10000); cout<<" s1.GetA() -> " << s1.GetA() << "\t"...
View Full Document

Ask a homework question - tutors are online