摘要:
有继承情形下 基类与子类的构造函数与析构函数运行顺序,如下代码: #include "stdafx.h" #include using namespace std; class A { public: A() { cout << "Base class constructor" << endl; } 阅读全文
posted @ 2019-10-15 11:32
tangjunjun
阅读(388)
评论(0)
推荐(0)
摘要:
我们知道c语言中可以整型数据或浮点型等做四则运算,而自己写的类也可做四则运算,是不是感觉奇怪,可以看以下代码是如何完成类之间的四则运算: #include "stdafx.h" #include using namespace std; class A { public: A(double r1=0 阅读全文
posted @ 2019-10-15 11:31
tangjunjun
阅读(329)
评论(0)
推荐(0)
摘要:
我在微博中已经提到继承的方式有三种(公有继承、私有继承、保护继承),然私有继承会将基类的公有成员变成私有成员。如果,我们想通过外部访问基类中的成员,则无法实现,原因在于私有继承将基类中的公有成员变成了私有成员。为此,我们将想办法将子类中私有成员(基类的公有成员)变成子类公有成员,则需用到“::”此符 阅读全文
posted @ 2019-10-15 11:31
tangjunjun
阅读(122)
评论(0)
推荐(0)
摘要:
类模板 #include "stdafx.h" #include using namespace std; template class A { public: A(double r1,double i1) { r = r1; i = i1; } //simple print(); simple p 阅读全文
posted @ 2019-10-15 11:29
tangjunjun
阅读(107)
评论(0)
推荐(0)
摘要:
#include "stdafx.h" #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int b=1; switch (b+2){ case 1 : { cout<<"b="<<b<<endl;} case 阅读全文
posted @ 2019-10-15 11:28
tangjunjun
阅读(133)
评论(0)
推荐(0)
摘要:
精确算法(Exact algorithm)指可求出最优解的算法。到目前为止,已提出的精确算法种类较多,有分支定界法、割平面法、整数规划算法和动态规划算法等。一般可用软体为 CPLEX LINGO GUROBI 启发式策略(heuristic)是一类在求解某个具体问题时,在可以接受的时间和空间内能给出 阅读全文
posted @ 2019-10-15 11:28
tangjunjun
阅读(4559)
评论(0)
推荐(0)
摘要:
int b=8; int c=0; c=++b; cout<<"c="<<c<<endl; cout<<"b="<<b<<endl; 结果为:c=9;b=9; int b=8; int c=0; c=b++; cout<<"c="<<c<<endl; cout<<"b="<<b<<endl; 结果为 阅读全文
posted @ 2019-10-15 11:26
tangjunjun
阅读(144)
评论(0)
推荐(0)
摘要:
指针的一些总结 const与指针 指向const的指针指的是指针指向的数据是常量,不可以被修改,但指针变量本身可以被修改,如const int *p;严格说不能用指针间接修改指向的数据,但该变量可以通过自己本省修改。如 int a=10; const int *p=&a;则*p=9是错误的,无法被修 阅读全文
posted @ 2019-10-15 11:25
tangjunjun
阅读(255)
评论(0)
推荐(0)
摘要:
#include "stdafx.h" #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { char buffer[134]; cin>>buffer; int len=(int) strlen(buffer);/ 阅读全文
posted @ 2019-10-15 11:25
tangjunjun
阅读(128)
评论(0)
推荐(0)
摘要:
头文件格式 主要声明,如函数,变量等 源文件说明头文件声明的定义 头文件与源文件总体框架与架构 头文件与源文件总体框架与架构 阅读全文
posted @ 2019-10-15 11:24
tangjunjun
阅读(370)
评论(0)
推荐(0)