上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: student.h: #ifndef STUDENT_H #define STUDENT_H #include <QObject> class Student:public QObject { Q_OBJECT public: Student(); public slots: void Answer 阅读全文
posted @ 2020-07-07 11:41 sunshine_gzw 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 代码示范: #include<iostream> using namespace std; class A { public: void foo() { cout << "A()" << endl; } }; class B :public A { public: void foo() { cout 阅读全文
posted @ 2020-07-06 16:58 sunshine_gzw 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; class Book { public: void getContent() { cout << "从前有座山,山上有座庙,庙里有个小和尚,小和尚在听老和尚讲故事,从前有座山..." << endl; } }; clas 阅读全文
posted @ 2020-07-06 16:19 sunshine_gzw 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 如果一个对象,只是希望他可以被创造出来,不希望被拷贝,那么最先想到的应该是将拷贝和复制运算符私有化: class A { public: A(){} ~A(){} private: A(const A&){} A& operator=(const A&) {} }; 但是书中大师认为,有两类函数仍然 阅读全文
posted @ 2020-07-04 21:23 sunshine_gzw 阅读(105) 评论(0) 推荐(0) 编辑
摘要: class A { public: A(int x=0,int y=0) { cout << "aaaaa" << endl; } }; int main() { A a(1,2); A b{1,2}; while (1); return 0; } (箭头表示调用该构造函数) 这两种初始化都会成功编 阅读全文
posted @ 2020-07-02 16:50 sunshine_gzw 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 有了以上基础思想,接下来引入规则,就直接上例子告诉你怎么做,理解到这感觉就够了,内部具体怎么实现的能力有限,也不能回答,接下来以下面例子为例: #include<iostream> #pragma pack(4) using namespace std; class A { public: char 阅读全文
posted @ 2020-06-29 19:13 sunshine_gzw 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 先看如下代码: #include<iostream> using namespace std; class Base1 { public: }; class Base2 { public: char ch; }; class Base3 { public: int ch; }; class Base 阅读全文
posted @ 2020-06-29 13:30 sunshine_gzw 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 问题: 对于一个字节(8位)的无符号整型变量,求二进制中1的个数。 分析: 法一: (n%2)==1则二进制数n的最低位为1,用count记录下,接下来n减半; n/=2; (比如 11101001变为 01110100) 所以最基础版的代码如下: int GetAnswer1(unsigned c 阅读全文
posted @ 2020-06-28 15:27 sunshine_gzw 阅读(689) 评论(0) 推荐(0) 编辑
摘要: 标准写法: #include<iostream> #include<thread> using namespace std; void MyThread() { cout << "MyThread线程1开始了" << endl; cout << ".................." << end 阅读全文
posted @ 2020-06-26 21:06 sunshine_gzw 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 带有虚基类的情况。 1 #include<iostream> 2 using namespace std; 3 class X 4 { 5 public: 6 int i; 7 }; 8 class A:public virtual X 9 { 10 public: 11 int j; 12 }; 阅读全文
posted @ 2020-06-23 11:51 sunshine_gzw 阅读(149) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 下一页