小工具知识网

当前位置: 首页 > 行业知识 > C++——类和对象(2)

行业知识

C++——类和对象(2)

2026-11-26 12:50:34 来源:互联网转载

1. 类的6个默认成员函数

当一个���中什么都没有,编译器会帮类自动生成6个默认成员函数例如:

class Date{};

此篇文章主要围绕构造函数与析构函数进行讲解。


2. 构造函数

2.1 概念

#define  _CRT_SECURE_NO_WARNINGS 1#include using namespace std;class Date{private:int _year;int _month;int _day;public:void Init(int year = 1,int month = 1 ,int day = 1){this->_year = year;this->_month = month;this->_day = day;cout 

上一篇:电脑屏幕封装图解教程大全

下一篇:服务器硬盘如何查看?