我的 C++ style

 1 int g_tennis;    // not use as possible
 2 
 3 int make_world() {
 4     int size = 0;
 5 
 6     return size;
 7 }
 8 
 9 const int NUMBER = 100;
10 
11 enum Color {
12     RED,
13     GREEN
14 };
15 
16 typedef int Dog;
17 
18 class MyClass {
19     public:
20         MyClass(int s, int num_entries = 0)
21             : size(s), num_entries_(num_entries), length_(0) {
22                 int book = NUMBER;
23                 book = 3;
24             }
25 
26         int size;
27 
28         // same as data member
29         int num_entries() const {
30             return num_entries_;
31         }
32 
33         void set_num_entries(int num_entries) {
34             num_entries_ = num_entries;
35         }
36 
37         // private and protected name end with underline
38     private:
39         int num_entries_;
40 
41         void foo_(double world) {
42             double *pworld = &world;
43             pworld = nullptr;
44         }
45 
46     protected:
47         int length_;
48 };
49 
50 int main() {
51 
52     return 0;
53 }

 

posted on 2015-07-15 14:24  jjtx  阅读(335)  评论(1编辑  收藏  举报

导航