![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++学习
兴隆山的风
这个作者很懒,什么都没留下…
展开
-
字符串与数值转化
使用前提:编译器支持c++11标准一:字符串转成数值#include<iostream>#include<string>//函数都包含在<string>文件中using namespace std;int main(){ string str="123.123"; int t; long l; float f; double d; t=stoi(str,0,10);//第一个形参:字符串变量,第二个:字符串的起始位置,第三个:想要转换原创 2021-08-12 00:15:27 · 5166 阅读 · 1 评论 -
c++文件读写
ios::in:打开输入文件,可防止文件内容删除,但是输入内容时从文件第一个位置开始并且会覆盖后面的内容ios::ate:如果没有文件,生成空文件;如果有文件,清空该文件ios::app:如果没有文件,生成空文件;如果有文件,在文件尾追加ios::trunc打开某个文件时,如果没有上述三个中任意一个指定,就会默认...原创 2021-08-19 23:41:10 · 1013 阅读 · 0 评论 -
类的组合与继承一些易混点
组合特点:有一个嵌入对象 通过初始化列表初始化(数据的名字)(形参表里面数据类型为“类”类型); 传递嵌入对象时会调用复制构造函数(复制构造函数形参前最好加const,否则很容易报错);继承特点:是一个,具有基类的特点; 初始化列表里直接调用基类构造函数(即基类的名字)(形参表里面包含基类的数据成员);两者在构造函数和复制构造函数函数中,初始化的方式不一样。嵌入的对象是用对象的名字,而类使用类...原创 2021-08-13 21:43:51 · 1030 阅读 · 0 评论 -
继承、派生类特点
1.公有继承:2.私有继承:3.保护继承:4.保护成员特点、作用:原创 2021-08-12 14:19:17 · 1296 阅读 · 0 评论 -
realloc函数实现数组动态增长
realloc函数有两种机制:#include<stdio.h>#include<stdlib.h>intmain(){ int*p = (int*)calloc(10,sizeof(int));printf("%p",p);for(inti = 0; i < 10; i++){*(p + i) = i;...转载 2021-08-11 14:43:04 · 1320 阅读 · 0 评论 -
const int*p、int const *p、int* const p及const int* const p区别
一、const int*p、int const *p两者的意义一样例: int a,b; const int* p=&a; p=&b; //正确 *p=2; //错误 该指针p可以再指向其他对象,但是不能修改对象的值; ...原创 2021-08-09 22:30:31 · 2117 阅读 · 0 评论