指针总结

来源:互联网 发布:什么是数据生态圈 编辑:程序博客网 时间:2024/06/06 13:56

#include<iostream>

using namespace std;

class Time

{

public(int ,int,int );

void show_Time();

void reset_time();

private:

int hour;

int minute;

int sec;

};

Time::Time(int h,int m,int s)

{

hour=h;

minute=m;

sec=s;

}

void Time::show_Time()

{

count<<hour<<":"<<minute<<":"<<sec<<endl;

}

.........//省略写

容易容混的几个概念

1:常对象 (以上述代码为例)Time  const t;

2:常成员函数  void Time::fun()const;不能修改类中数据成员。

3:常指针:Time *const p;p的指向不能改变。

4:常对象指针:const Time *p;类对象的值不能通过指针来实现。

5:对象的动态创建与释放: Time *p=new Time(int ,int,int );

6:对象的复制和赋值:t1=t2;把后者赋值给前者,而不是对成员函数赋值。

2 0
原创粉丝点击