上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: 1 #include 2 using namespace std; 3 4 class ClassA 5 { 6 int member; 7 8 public: 9 ClassA (int x):member(x)10 {11 cout << member <<endl;12 }13 14 friend ClassA Add(const ClassA& a, const ClassA& b);15 };16 17 //习惯使用引用来避免参数复制,提高效率,使用const避免修改 18 ClassA Add(cons... 阅读全文
posted @ 2014-03-20 22:03 秋月的私语 阅读(438) 评论(0) 推荐(0)
摘要: 提示,一般不要修改常量的值,没意义!不同的编译器有不同的处理方式。特殊的时候才需要考虑: 1 #include 2 using namespace std; 3 class A{ 4 const int a; 5 public: 6 A(int i):a(i){} 7 const int& geta()const{ 8 return a; 9 }10 };11 int main(){12 //这个可以改13 A a(10);14 cout 2 using namespace std; 3 class B 4 { 5 pub... 阅读全文
posted @ 2014-03-19 21:38 秋月的私语 阅读(1426) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 class B 4 { 5 public: 6 B() { } 7 public: 8 int m_iNum; 9 };10 void foo()11 {12 const B b1;13 //b1.m_iNum = 100; //compile error14 //上面注释掉的代码编译时会报错,因为b1是一个常量对象,不能对它进行改变;15 // 可以做如下转换,体现出转换为指针类型16 B *b2 = const_cast(&b1);17 // 或者左侧... 阅读全文
posted @ 2014-03-17 22:57 秋月的私语 阅读(160) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 4 class MyClass1 5 { 6 public: 7 int a; 8 void Show(bool bSwitch) const //对应const 类 ,注意const的位置 9 {10 cout a = a;16 }17 private:18 int b; 19 };20 21 class MyClass2 : public MyClass122 {23 public:2... 阅读全文
posted @ 2014-03-09 00:28 秋月的私语 阅读(246) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 4 class MyClass1 5 { 6 public: 7 int a; 8 void Show(bool bSwitch) 9 {10 cout << "a=" << a << endl;11 }12 private:13 int b; 14 };15 16 class MyClass2 : public MyClass117 {18 public:19 int c;... 阅读全文
posted @ 2014-03-07 21:37 秋月的私语 阅读(1292) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 class Test1 4 { 5 public: 6 int m; 7 Test1(int n) { num = n; } //普通构造函数 8 void Show() 9 {10 cout << "private num = " << num <<endl;11 }12 private:13 int count;14 int num;15 int n;16 };17 class Test218 {19 public:20 exp... 阅读全文
posted @ 2014-03-04 20:27 秋月的私语 阅读(308) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 4 class as 5 { 6 public: 7 int a; 8 const int b; 9 as():b(2)10 {11 a = 1;12 }13 ~as()14 {15 cout 2 using namespace std; 3 4 class A 5 { 6 public: 7 A() 8 { 9 cout << "A()" << endl;10 }11 ... 阅读全文
posted @ 2014-02-28 21:29 秋月的私语 阅读(312) 评论(0) 推荐(0)
摘要: 1 private void BtnClickSaveCSV(object sender, EventArgs e) 2 { 3 checkBoxHideUseless.Checked = false; 4 int nColumns = nColumnsExist; 5 int nRows = dataGridView1.RowCount; //去掉最后的新行 6 string szToBeStored = "", szDelLogs = "", szMoveLogs = ""; 7 Stopwatch sw = new Stopwa 阅读全文
posted @ 2014-02-26 16:21 秋月的私语 阅读(399) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 4 struct Mys 5 { 6 int a; 7 void change(int a); 8 void show(int b); 9 };10 11 12 int main(int argc, char *argv[])13 {14 Mys mys_a;15 //给成员变量赋值 16 mys_a.a= 10;17 int d = 100;18 mys_a.change(d);19 //成员函数修改成员变量 20 mys_a.show... 阅读全文
posted @ 2014-02-25 22:25 秋月的私语 阅读(224) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 4 void show() 5 { 6 static int i = 0; 7 long t = time(NULL); 8 while(t == time(NULL)); 9 cout << "当前是第 " << i++ <<" 秒;" << endl;10 }11 12 int main(int argc, char *argv[])13 {14 for(;;)15 show();16 return 0;17 } 阅读全文
posted @ 2014-02-25 21:26 秋月的私语 阅读(206) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 下一页