c++定义对象总结测试 #include <iostream>using namespace std;class AAA{public: int a; AAA() { std::cout << "AAA()" << std::endl; } AAA(int) { std::cout << "AAA(int)" << std::endl; }};int main(){ AAA aaa1;//AAA() AAA.
Ubuntu下显示Git仓库分支信息 1. vim ~/.bashrc2. 到最后一行写入如下代码#show the current git branch find_git_branch () { local dir=. head until [ "$dir" -ef / ]; do .
简单明了QComboBox 1. QComboBox * comboBox = new QComboBox()2. comboBox->addItem("文字项1");comboBox添加一项3. comboBox->addItem(QIcon(".PNG"), "文字项"); comboBox添加带文字的一项4. Signal::currentIndexChanged(int); comboBox改...
简单明了QCheckBox 1. QCheckBox * checkBox = new QCheckbox("标签内容", 父窗口)2. checkBox->checkState();被选择返回1,否则返回03. checkBox->setIcon(QIcon(":/*.png"));设置CheckBox文字前的图片,如下图...
常用的运算符优先级(由上至下) 逻辑运算符 NOT 符号 : !算数运算符 : * / %算数运算符 : + -关系运算符: < > <= >=关系运算符: == !=逻辑运算符 AND 符号 : &&逻辑运算符 OR 符号 : ||赋值运算符: ...
Visual Studio 2017资源下载 Windows:Visual Studio 2017 Community :https://visualstudio.microsoft.com/zh-hans/thank-you-downloading-visual-studio/?sku=Community&rel=15Visual Studio 2017 Professional:https://visuals...
namespace 1. 命名空间作用防止命名冲突2. 命名空间常见的用法2.1 全局域中定义的名字被隐式的添加到全局命名空间中每个命名空间都是一个作用域#include <iostream>int a = 0;int main(){ int a = 0; ::a = 1; a = 2; //std::cout<<a<<s...
try...catch...流程图示 1. 语法形式before try codetry{ before throw; throw expection; after throw;}catch(expection1){}catch(expection2){}catch(expection3){}catch(...){}after try code2. 逻辑当try语句中...
Interpret #include <iostream>#include <map>#include <stack>using namespace std;class Expression{public: virtual int interpret(map<char, int>var) = 0; virtual ~Expression(...
Interpret(Reference:Design Patterns - Elements of Reusable Object-Oriented Software) AbstractExpression--- 声明一个抽象的解释操作,这个接口为抽象语法树中所有的节点共享TerminalExpression--- 实现与文法中的终结符相关联的解释操作--- 一个句子中的每个终结符需要该类的一个实例NonterminalExpression--- 解析文法中的其他规则Context--- 包含解释器之外的一些全局信息...
Visitor #include <iostream>using namespace std;class ElementA;class ElementB;class Visitor{public: virtual ~Visitor(){} virtual void visitElementA(ElementA & element) = 0; virt...
Visitor(Reference:Design Patterns - Elements of Reusable Object-Oriented Software) Visitor--- 为对象结构中ConcreteElement的每一个类声明一个Visit操作!该操作的名字和特征标识了发送Visit请求给该访问者的类。使得访问者可以确定正在被访问元素的具体的类。这样访问者就可以通过该元素的特定接口直接访问它。ConcreteVisitor--- 实现每个由Visitor声明的操作。每个操作实现本算法的一部分,该算法是对应于结构中对象的类。Conc...
Command #include <iostream>#include <vector>#include <string>using namespace std;class Receiver{public: virtual ~Receiver(){} virtual void action() = 0;};class Receive1 : ...
Command(Reference:Design Patterns - Elements of Reusable Object-Oriented Software) Command--- 声明执行操作的接口ConcreteCommand--- 将一个接收者对象绑定与一个动作--- 调用接收者相应的操作,以实现Execute。Client--- 创建一个具体命令对象并设定它的接收者Invoker--- 要求该命令指向这个请求Receiver--- 知道如何实施与执行一个请求相关的操作。任何类都可能成为一个接收者。...
Iterator #include <iostream>using namespace std;template<typename T>class Iterator{public: virtual ~Iterator(){} virtual void first() = 0; virtual void next() = 0; virtual bo...
Iterator(Reference:Design Patterns - Elements of Reusable Object-Oriented Software) Iterator--- 迭代器定义访问和遍历元素的接口。ConcreteIterator--- 具体迭代器实现迭代器接口--- 对该聚合遍历时跟踪当前位置。Aggregate--- 聚合定义创建相应迭代器对象的接口。ConcreteAggregate--- 具体聚合实现创建相应迭代器的接口,该操作返回ConcreteIterator的一个适当的实例。...
ChainOfResponsibility #include <iostream>using namespace std;enum Level{ Level_One = 1, Level_Two, Level_Three, Level_Four };class LevelRequest{public: LevelRequest(LevelRequest * levelRequest) : m_levelR...
ChainOfResponsibility(Reference:Design Patterns - Elements of Reusable Object-Oriented Software) Handler--- 定义一个处理请求的接口--- (可选)实现后继链ConcreteHandler--- 处理它所负责的请求--- 可访问它的后继者--- 如果可处理该请求,就处理;否则将该请求转发给它的后继者。...
Composite #include <iostream>#include <list>using namespace std;class Component{public: virtual ~Component(){} virtual void process() = 0;};class Leaf : public Component{public: ...