摘要: ```cpp#include #include #include #include struct Base { virtual void f() { std::cout init(); return ret;}void testVirtual() { //Base b; //Derived d; ////虚函数调用通过引用 ////virtual funciton call through ref... 阅读全文
posted @ 2020-02-24 19:07 i0gan 阅读(675) 评论(0) 推荐(0)
摘要: ```cpp #include #include /* 类虚函数遇到构造和析构就退化了 */ class Event; //类的前置声明 class Event {}; class Base { public: virtual ~Base() {} //why? virtual Base(int _id) : m_id(_id) {} virtual void act(Event const&) 阅读全文
posted @ 2020-02-24 19:04 i0gan 阅读(189) 评论(0) 推荐(0)
摘要: ```cpp#include #include static void versionOne();static void versionTwo();using namespace std;int main(void) { versionOne(); versionTwo(); versionThree(); return EXIT_SUCCESS;}void versionOne() { //c语... 阅读全文
posted @ 2020-02-24 19:01 i0gan 阅读(273) 评论(0) 推荐(0)
摘要: ```cpp#include #include #include #include /* 建议: 在类的构造函数中抛出异常 */class A { public: A() {}};class B : public A { public: B() {} ~B() { /*std::cout m_info; //若作为状态判断,一般声明为私有函数, 通过assert来提示. bool i... 阅读全文
posted @ 2020-02-24 18:55 i0gan 阅读(273) 评论(0) 推荐(0)
摘要: ```cpp#include /* 不要在析构函数中抛出异常 */class A { public: A() {} ~A() { std::cout << "A析构了.." << std::endl; }};/* 析构函数调用规则: 先调用成员析构 再调用派生类析构 *///析构函数绝对不要抛出异常class B : public A{ public: B() {} ~B() { std... 阅读全文
posted @ 2020-02-24 18:52 i0gan 阅读(655) 评论(0) 推荐(0)
摘要: ```cpp #include #include #include #include #include class RuleOfFive; //前置声明class class Parent; class Child { public: explicit Child(Parent *p) : m_parent(p) {} private: Parent *m_parent; }; class Par 阅读全文
posted @ 2020-02-24 18:46 i0gan 阅读(639) 评论(0) 推荐(0)
摘要: QT_6 常用控件 Qt为我们应用程序界面开发提供的一系列的控件,下面我们介绍两种最常用的两种,所有控件的使用方法我们都可以通过帮助文档获取。 QLabel QLabel是我们最常用的控件之一,其功能很强大,我们可以用来显示文本,图片和动画等。 显示文字 (普通文本、html) 通过QLabel类的 阅读全文
posted @ 2020-02-05 18:15 i0gan 阅读(599) 评论(0) 推荐(0)
摘要: QT_5 QDialog 基本概念 对话框是 GUI 程序中不可或缺的组成部分。很多不能或者不适合放入主窗口的功能组件都必须放在对话框中设置。对话框通常会是一个顶层窗口,出现在程序最上层,用于实现短期任务或者简洁的用户交互。 Qt 中使用QDialog类实现对话框。就像主窗口一样,我们通常会设计一个 阅读全文
posted @ 2020-02-05 17:42 i0gan 阅读(414) 评论(0) 推荐(0)
摘要: QT_4 QMainWindow QMainWindow是一个为用户提供主窗口程序的类,包含一个菜单栏(menu bar)、多个工具栏(tool bars)、多个锚接部件(dock widgets)、一个状态栏(status bar)及一个中心部件(central widget),是许多应用程序的基 阅读全文
posted @ 2020-02-05 15:54 i0gan 阅读(149) 评论(0) 推荐(0)
摘要: QT_3 坐标系统与对象模型 Qt窗口系统 坐标体系 以左上角为原点,X向右增加,Y向下增加 对于嵌套窗口,其坐标是相对于父窗口来说的 QWidget 所有窗口及窗口控件都是从QWidget直接或间接派生出来的 对象模型 在Qt中创建对象的时候会提供一个Parent对象指针,下面来解释这个paren 阅读全文
posted @ 2020-02-05 15:18 i0gan 阅读(172) 评论(0) 推荐(0)