C++
顾苏子
这个作者很懒,什么都没留下…
展开
-
new和delete重载
#include<iostream> using namespace std; /* new: new operator:申请空间+调用构造 不可以重载 operator new:申请空间 可以重载 delete: delete operator:调用析构+释放空间 不可以重载 operator delete:释放空间 可以重载 */ class Node { public: Node(int a=0,int b=0)//构造 { c原创 2021-09-08 19:50:02 · 70 阅读 · 0 评论 -
C++ 2021-5-20笔记
#include<iostream> using namespace std; class Stu { public: char*_name; int _age; bool _sex; // 0 女 1 男 //构造 Stu() { cout << "Stu()" << endl; } //构造 Stu( const char * name , int age , bool sex) { cout << "Stu( c原创 2021-05-20 21:21:24 · 92 阅读 · 0 评论 -
面向对象 2021-5-19
语句:数据+函数 C++中增加了对象 面向对象的三大特征:封装、继承、多态 面向对象的四大特征:抽象、封装、继承、多态 C实现封装: #include<iostream> #include<stdio.h> using namespace std; struct Cgoods { char*_name; int _price; void (*init)(struct Cgoods *good , char * name,int price); void (*copy)(s原创 2021-05-19 21:21:56 · 81 阅读 · 0 评论 -
C和C++的区别
默认值参数 C语言不存在给函数参数默认赋值 int fun(int a,int b,int c=30) { cout<<a<<endl; cout<<b<<endl; cout<<c<<endl; return 0; } 函数参数默认值必须从右向左依次赋值; 函数参数默认值优先级在调用时候传参之后; 函数参数的默认值可以再定义地方进行设定,也可以在声明的地方设定; 一个函数参数默认值只能设定一次; 函数不同参原创 2021-05-13 21:28:50 · 153 阅读 · 0 评论