C++ 速查手冊 V1.00 - 單元 13 範例




u1303_1.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
  
int main() {
   typedef int INTEGER;
   INTEGER a = 22;
   std::cout << "a: "
             << a
             << std::endl;
 
   return 0;
}
  
/* Kaiching Chang
   u1303_1.cpp
   2014-02 */

u1303_2.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
 
struct SomethingWillHappened {
   int a;
};
  
typedef SomethingWillHappened SHDemo;
  
int main() {
   SHDemo d;
   d.a = 22;
 
   std::cout << "d.a: "
             << d.a
             << std::endl;
 
   return 0;
}
  
/* Kaiching Chang
   u1303_2.cpp
   2014-02 */

u1305_1.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
 
int main() {
   const int a = 22;
   std::cout << "a: "
             << a
             << std::endl;
 
   a = 1;
 
   return 0;
}
  
/* Kaiching Chang
   u1305_1.cpp
   2014-02 */

u1305_2.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
 
int main() {
   const int End = 0;
   for (int i = 10; i > End; i--) {
      std::cout << i
                << std::endl;
   }
 
   return 0;
}
  
/* Kaiching Chang
   u1305_2.cpp
   2014-02 */

the end

沒有留言: