1 #include <iostream> //引用头文件(输入输出) 2 3 using namespace std; //引用命名空间,方便使用输入输出语句 4 5 class MathMethod 6 { 7 public: 8 int a; 9 int b; 10 MathMethod(int aa, int bb); 11 ~MathMethod(); 12 int AddInt(); 13 }; 14 15 MathMethod::MathMethod(int aa, int bb) 16 { 17 a = aa; 18 b = bb; 19 } 20 MathMethod::~MathMethod(){} 21 22 int MathMethod::AddInt() 23 { 24 return a + b; 25 } 26 27 int AddInt(int a, int b) 28 { 29 return a + b; 30 } 31 32 int main() 33 { 34 int abc(11); 35 int adc[]{ 22, 33 }; 36 for (int i = 0; i < 2; i++) 37 { 38 cout << adc[i] << endl; 39 } 40 41 char ch; 42 cin >> ch;//输入 43 cout << ch << endl;//输出 44 wchar_t wch = 'a'; 45 cout << wch << endl;//输出ascll值 46 47 int a, b; 48 cin >> a; 49 cin >> b; 50 int c; 51 c = AddInt(a, b); 52 MathMethod mm(a, b); 53 int d = mm.AddInt(); 54 cout << "a + b = " << c << endl; 55 cout << "a + b = " << d << endl; 56 system("pause"); 57 return 0; 58 }