C++
voiiid
这个作者很懒,什么都没留下…
展开
-
const_详解
.h #pragma once //本头文件用来学习const用法 使用const的常见原因:提高效率 #include <iostream> using namespace std; //1,const修饰成员变量 void ConstDemo1() { int num1 = 210; const int num2 = num1; //num2=100;错误,const不能再改动 cout << num2 << endl; //const修饰指.原创 2021-02-08 23:23:36 · 147 阅读 · 0 评论 -
C++_使用类
1.运算符重载 2.友元 3.一元运算符重载 4.重载<<运算符 5.类的自动转换和强制类型的转换 1.运算符重载 梗概: 语法格式: 返回类型 operator被重载的运算符(参数列表) 实际调用(本质):int3=int1.opreator+(num2) 注意:可以把 “opreator+” 整个看成一个特殊函数 1.简化函数调用方式 2.例子 .h //自己定义的整型类(将整型封装成类) //Integar:整型 class Integar { private: int m_.原创 2021-02-07 20:58:44 · 119 阅读 · 0 评论 -
实例->学生成绩录入
1.memcpy的使用 2.this指针 3.关于清理内存的方法和位置 student .h文件部分 #include <iostream> #include <string> using namespace std; class student { private: float* scores;//学生的分数数组 int scorecnt;//学生成绩个数 public: student(); ~student(); void initscores();..原创 2021-02-06 15:11:25 · 368 阅读 · 0 评论 -
一些简单操作
1.快速注释 选中,ctrl+K,ctrl+C 2.取消注释 选中,ctrl+K,ctrl+U原创 2021-01-09 15:36:20 · 51 阅读 · 0 评论 -
C++_类与对象
1.本地头文件调用用的是双引号而不是尖角符号 e.g. #include "main.h" 2.string报错的时候在前面添加一个头文件string.h 必须要string.h和using namespace std一起写 3.不能直接使用对象的私有成员 private里面的东西不可以在外部使用 4.两个冒号代表从属关系,实现类中定义函数 class landownerV2 { private: string name; int cards[20]; long score; public: lan原创 2021-01-09 15:36:48 · 286 阅读 · 0 评论