随笔分类 -  C++

摘要:关于C++前置声明 举下面一个例子: //a.h文件 #pragma once#include "b.h"#include <iostream>using namespace std;class A{public: B *b1; void func1() { cout << "nihao shiji 阅读全文
posted @ 2020-03-02 14:43 A_Powered 阅读(367) 评论(0) 推荐(0)
摘要:C++产生随机数 C++中没有自带的random函数,要实现随机数的生成就需要使用rand()和srand()。 不过,由于rand()的内部实现是用线性同余法做的,所以生成的并不是真正的随机数,而是在一定范围内可看为随机的伪随机数。 srand() srand()可用来设置rand()产生随机数时 阅读全文
posted @ 2020-02-24 23:26 A_Powered 阅读(303) 评论(0) 推荐(0)
摘要:在C++中调用C语言 因为C++扩展了函数重载。编译时会将函数名修改,所以直接条用会出错。 #ifdef __cplusplusextern "C" {#endif // __cplusplus /* #include <stdio.h> void show() */ #ifdef __cplusp 阅读全文
posted @ 2020-02-19 11:23 A_Powered 阅读(256) 评论(0) 推荐(0)
摘要:类是对对象的抽象。 对象是对类的实例。 阅读全文
posted @ 2020-02-18 11:25 A_Powered 阅读(110) 评论(0) 推荐(0)
摘要:箭头(->):左边必须为指针; 点号(.):左边必须为实体。 阅读全文
posted @ 2020-02-17 19:28 A_Powered 阅读(122) 评论(0) 推荐(0)
摘要:指针:指针实质上就是一个变量,其值为另一个变量的地址,即,内存位置的直接地址。就像其他变量或常量一样,您必须在使用指针存储其他变量地址之前,对其进行声明。 int main(){ int a = 10; int *b = &a; int **c = &b; cout << a << endl; co 阅读全文
posted @ 2020-02-17 19:18 A_Powered 阅读(105) 评论(0) 推荐(0)