![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
wqyolo
这个作者很懒,什么都没留下…
展开
-
[C++]C++的成员对象和封闭类
前言讲解C++的封闭类,及构造函数和析构函数的调用顺序。#include<iostream>using namespace std;class CTyre{ public: CTyre(){ cout<<"CTyre contructor"<<endl; } ~CTyre(){ cout<<"CTyre contru...原创 2019-08-15 14:23:25 · 675 阅读 · 0 评论 -
[C++]C++的引用
前言用C语言和C++实现两个变量的交换。可见用C++实现,简洁多了。C实现:#include<stdio.h>void swap(int *a,int *b){ int tmp; tmp=*a;*a=*b;*b=tmp; }int main(){ int n1=23,n2=34; swap(&n1,&n2); printf("n1: %d\n...原创 2019-08-11 19:53:29 · 111 阅读 · 0 评论 -
[C++]C++的const&new
前言旨在复习C++的基本知识。引用常引用:不能通过常引用去修改其引用的内容。int n;const int & r=n;//不能通过修改r去修改nconst关键字和常量在C语言中,define用来定义常量,在C++中,多用const定义常量,它是有类型的,便于类型检查。const可以定义常量,常量引用,常量指针。int n;const int & r=...原创 2019-08-12 15:22:16 · 285 阅读 · 0 评论 -
[C++]C++的多态
前言多态的例子。涉及虚函数。#include<iostream>using namespace std;class A{ public: virtual void Print(){ cout<<"A::Print"<<endl; }}; class B:public A{ public: virtual void Print(...原创 2019-08-17 14:04:18 · 302 阅读 · 0 评论