c++学习
aLiegjln
这个作者很懒,什么都没留下…
展开
-
拷贝构造函数
#include<iostream>class CFrist{ int data;public: CFrist(int d=0)//构造函数 { data=d; } CFrist(CFrist &timp)//拷贝构造函数 { data=timp.data; } /*1.与构造函数一样,但参数是独特原创 2017-11-19 16:24:08 · 319 阅读 · 0 评论 -
关于类的构造函数
构造与析构函数析构函数的三大功能1.构造函数2.初始化函数3.类型转化原创 2017-11-05 13:56:05 · 653 阅读 · 1 评论 -
运算符重载,友元函数;
运算符重载#include<iostream>using namespace std;class CInt{friend ostream& operator<<(ostream& out,const CInt & timp);private: int i;public: CInt (int d) { i=d; }; CInt(cons原创 2017-12-19 22:47:12 · 361 阅读 · 0 评论 -
static 用法
c++ static 用法#include <iostream>using namespace std;/*静态意味着面对所有的对象,即属于类,属于类,不由对象调用.可以访问私有数据静态变量:相当于全局变量,,针对于同一类对象的全局变量静态函数:不能访问普通变量,只能访问静态变量;*/class Ctext{ static int n;//静态变量;...原创 2018-02-17 22:36:51 · 385 阅读 · 0 评论 -
模板函数
#include <iostream>using namespace std;/*把数据的类型也当做参数传入,减少代码重用,使代码不受类型的限制*/int maax(int a,int b){ return a>b?a:b;}double maax(double a,double b){ return a>b?a:b;}float m...原创 2018-02-17 22:41:32 · 402 阅读 · 0 评论 -
模板类
模板类,实现一个简单的单链表#include <iostream>#include <stdlib.h>using namespace std;template <typename type>class List;template <typename type>class note//此后这个类的类型就是 note<type&...原创 2018-02-17 22:43:44 · 332 阅读 · 0 评论 -
new&delete
new和delete的基本用法:#include <iostream>#include <stdlib.h>#define N 10using namespace std;class test{private: int a;public: test(int d=0) { a=d; cout<&...原创 2018-02-17 22:54:39 · 341 阅读 · 0 评论