![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
C++
C++基础知识
wxsy024680
这个作者很懒,什么都没留下…
展开
-
C++——afxrendertarget.h相关报警
解决措施:项目属性,C/C++,语言,符合模式设置为否。原创 2022-10-17 09:34:52 · 789 阅读 · 0 评论 -
C++——打印字符串
1、C++打印字符串时,可以使用如下代码对于CString格式或字符串数组格式的UNICODE字符,如,有可能打印不完全,因为有些UNICODE字符,第一个字节(前8位)为0,在打印时相当于遇到了结束符,所以结束了,这时可以尝试如下代码。...原创 2022-06-13 19:33:34 · 7501 阅读 · 0 评论 -
C++学习笔记——拾遗
1、指针大小sizeof(int *)为4,sizeof(float *)为4, sizeof(char *)也为4,存放地址4个字节就够了,int、float、char指的是地址上的数据的类型。2、空指针,如int * buf = NULL空指针指向内存编号为0x00000000的地方,此处是不可以读写的,一般用于指针初始化。其实0x00000000~0x000000FF之间的内存都是系统占用的,都不可以读写。3、野指针,如int * buf=(int *)0x000011000x0000110原创 2022-03-11 14:44:44 · 966 阅读 · 0 评论 -
C++学习笔记——安装visual studio 2013
1、安装Ultraiso;2、打开Ultraiso;3、点击“文件”->“打开”,打开保存在电脑上的ISO文件;4、选中ISO文件后,里面的内容就可以显示出来了;5、点击“工具”->“加载到虚拟光驱”,生成CD驱动器;6、打开“计算机”中的“CD驱动器”,双击.exe文件进行安装;...原创 2021-04-12 10:20:22 · 5252 阅读 · 0 评论 -
C++学习笔记——二进制文件的读写
二进制文件的读写是以字节为单位进行操作的,举例如下:#include<iostream>#include<fstream>#include<string.h>using namespace std;class Student{ private: char Name[10]; char Class[10]; char Sex; int Age; public: Student(){} Student(char *Name,char *C原创 2021-02-06 20:03:57 · 4876 阅读 · 0 评论 -
C++学习笔记——文本文件的读写
#include<iostream>#include<fstream>using namespace std;int main(){ //打开文件 ofstream out("test.txt"); if(!out){ cout<<"打开文件失败"<<endl; return 1; } //写文件 out<<"欢 迎 来 到 北 京!"; out.close();//关闭文件 //打开文件 ifstream原创 2021-02-06 18:33:41 · 4779 阅读 · 0 评论 -
C++学习笔记——运算符重载
运算符重载定义形式:<函数类型> <类名> :: operator <操作符> (<参数表>){函数体{备注:不能重载的运算符包括"::",".",".*","?:"#include<iostream>using namespace std;class Complex{ public: double real, imag; public: Complex(double r=0, double i=0){real=r;i原创 2021-02-06 17:33:41 · 4777 阅读 · 0 评论 -
C++学习笔记——抽象类与纯虚函数
一、抽象类1、抽象类不能实例化;2、抽象类只作为基类被继承;3、可以定义抽象类的指针或引用;4、含有纯虚函数的类即为抽象类;二、纯虚函数1、纯虚函数定义:virtual 返回类型 函数名(参数表)= 02、纯虚函数具体实现只能在派生类中完成;#include<iostream>using namespace std;#define PI 3.14class Shape{ public: virtual double Area()=0;};class Rectan原创 2021-02-06 16:08:19 · 4841 阅读 · 0 评论 -
C++学习笔记——对象指针与函数指针
对象指针与函数指针的定义及使用:#include<iostream>using namespace std;class Date{ public: int year,month,day; void init(int y,int m,int d); void print();}; void Date::init(int yy,int mm,int dd){ year=yy; month=mm; day=dd;}void Date::print(){ cout&l原创 2021-02-06 15:13:57 · 4862 阅读 · 0 评论 -
C++学习笔记——构造函数与析构函数
构造函数的功能是初始化数据,析构函数的功能是在撤销对象之前进行一些善后处理工作#include<iostream>#include<string.h>using namespace std;class Person{ private: char Name[9]; int Age; char Sex; public: Person(){ strcpy(Name,"XXX"); Age=0; Sex=' '; } ~Person(){原创 2021-02-06 15:12:56 · 4933 阅读 · 1 评论 -
C++学习笔记——类的调用
类与类之间可以继承,也可以调用,下面的代码是演示Circle类是如何调用Point类的#include<iostream>using namespace std;class Point{ private: int x, y; public: void initPoint(int a, int b); double getX(){return x;}; double getY(){return y;}; void print();};void Point::ini原创 2021-02-06 14:45:09 · 5303 阅读 · 0 评论 -
C++学习笔记——多态
1、virtual关键字当基类和派生类存在同名函数时,基类的函数前加上virtual关键词,可以确保派生类的函数正常执行。#include<iostream>using namespace std;class pet{ public: void speak(){cout<<"zzz"<<endl;}};class dog:public pet{ public: void speak(){cout<<"wang!wang!wang!"&l原创 2021-02-06 11:40:16 · 4796 阅读 · 0 评论 -
C++学习笔记——构造函数与析构函数
一、派生类构造函数的执行顺序:1、调用基类构造函数,调用顺序按照它们被继承时声明的基类名顺序执行;2、调用内嵌对象构造函数,调用顺序按各个对象在派生类内声明的顺序;3、执行派生类构造函数体中的内容;二、派生类析构函数的执行顺序与构造函数相反:1、执行派生类析构函数;2、执行内嵌对象的析构函数;3、执行基类析构函数;#include<iostream>#include<string.h>using namespace std;class Person{ prot原创 2021-02-06 10:27:56 · 4815 阅读 · 0 评论 -
C++学习笔记——继承方式与访问限定
原创 2021-02-05 23:07:14 · 4755 阅读 · 0 评论 -
C++学习笔记——播放音乐
1、设置Dev C++编译器,工具->编译选项->编译器->在连接器命令行加入以下命令-lwinmm;2、预先下载mp3歌曲,与可执行文件放在同一目录;3、运行程序;#include<iostream>#include<windows.h>#include<string.h>#include<mmsystem.h> //媒体控制函数的头文件 using namespace std;int main(){ char play原创 2021-02-05 21:13:28 · 7522 阅读 · 1 评论 -
C++学习笔记——this指针
1、this指针指向本类对象的起始地址;2、当类中数据成员与成员函数中的形参名相同时,用this指针加以区分;#include<iostream>using namespace std;class Test{ private: int x; public: Test(int = 0); void print();}; Test::Test(int a){x=a;}void Test::print(){ int x = 20; cout<<"x="&l原创 2021-02-05 20:03:48 · 4828 阅读 · 0 评论