C++
程序员不穿格子衫
这个作者很懒,什么都没留下…
展开
-
何为耦合与解耦
一、耦合1、耦合是指两个或两个以上的体系或两种运动形式间通过相互作用而彼此影响以至联合起来的现象。2、在软件工程中,对象之间的耦合度就是对象之间的依赖性。对象之间的耦合越高,维护成本越高,因此对象的设计应使类和构件之间的耦合最小。3、分类:有软硬件之间的耦合,还有软件各模块之间的耦合。耦合性是程序结构中各个模块之间相互关联的度量。它取决于各个模块之间的接口的复杂程度、调用模块的方式以及哪些信...原创 2020-04-19 16:37:57 · 532 阅读 · 0 评论 -
初识:何为按需建构
按需建构,顾名思义,就是按照指定的需求去构建某些东西,在编程上必然是构建函数(方法)以及…C++在按需建构上出了一个花招,在函数内声明的静态变量并不会于main()之前建构,而是在第一次调用该函数时才建构。如果把全局单例改为静态变量,我们就可以控制全局单例的建构次序。(话不多说 上代码)class RenderManager{ public : //取得唯一实例 s...原创 2020-04-01 23:17:45 · 197 阅读 · 0 评论 -
C++中delete是如何工作
#include “pch.h”#include < iostream >#include < string >#include < cstring >#pragma warning(disable:4996)using namespace std;char * getname(void);char * getname(){char temp[...原创 2019-04-24 20:06:41 · 297 阅读 · 0 评论 -
C++使用new创建一个未命名的结构,并演示两种访问结构成员的指针表示法
#include < iostream >struct inflatable{char name[20];float volume;double price;};int main(){using namespace std;inflatable * ps = new inflatable;cout << " Enter name of inflatab...原创 2019-04-24 19:46:17 · 225 阅读 · 0 评论 -
C++如何使用不同形式的字符串
#include < iostream >int main(){using namespace std;char animal[20] = “bear”;const char * bird = “wren”;char * ps;cout << animal << " and ";cout << bird << “\n”;...原创 2019-04-24 17:37:32 · 106 阅读 · 0 评论 -
C++指针、数组和指针算数
include< iostream >int main(){using namespace std;double wages[3] = { 10000.0,20000.0,30000.0 };short stacks[3] = { 3,2,1 };double * pw = wages;short * ps = &stacks[0];cout <<...翻译 2019-04-22 20:05:34 · 218 阅读 · 0 评论 -
C++如何使用new来创建动态数组以及使用数组表示法来访问元素
#include < iostream>double * p3 = new double[3];p3[0] = 0.2;p3[1] = 0.5;p3[2] = 0.8;cout << "p3[1] is " << p3[1] << "." << endl;p3 = p3 + 1;cout << "Now p3[0...转载 2019-04-22 19:28:26 · 1786 阅读 · 0 评论 -
C++比较数组、vector对象、array对象
#include “pch.h”#include < iostream>#include < vector>#include < array>int main(){using namespace std;double a1[4] = { 1.2,2.4,3.6,4.8 };vector<double> a2(4);a2[0] = 1...原创 2019-04-26 16:07:33 · 442 阅读 · 0 评论 -
C++类型结合
#include < iostream >struct antarctica_years_end{int year;};int main(){antarctica_years_end s01, s02, s03;s01.year = 1998;antarctica_years_end * pa = &s02 ;pa->year = 1999;anta...原创 2019-04-26 15:09:35 · 243 阅读 · 0 评论 -
C++如何声明指针
// pointer.cpp#include < iostream>int main(){using namespace std;int updates = 6;int * p_updates;p_updates = &updates;cout << "Values : updates = " << updates;cout <&...转载 2019-04-21 15:40:06 · 2500 阅读 · 0 评论 -
C++指针和自由存储空间问题
#include < iostream>int main(){using namespace std;int donuts = 6;double cups = 4.5;cout << " donuts value = " << donuts;cout << " and donuts address = " << &...翻译 2019-04-21 15:30:17 · 135 阅读 · 0 评论