阅读程序
来源:互联网 发布:喜马拉雅有mac版吗 编辑:程序博客网 时间:2024/06/10 07:36
#include <iostream>using namespace std;class Time{public: Time(int,int,int); void output_time( ); int hour; int minute; int sec;};Time::Time(int h,int m,int s){ hour=h; minute=m; sec=s;}void Time::output_time( ){ cout<<hour<<":"; cout<<minute<<":" <<sec<<endl;}int main( ){ Time t1(10,13,56); int *p1=&t1.hour; //指向数据成员的指针 cout<<*p1<<endl; t1.output_time( ); Time *p2=&t1; //指向对象的指针 p2->output_time( ); void (Time::*p3)( ); //指向成员函数的指针 p3=&Time::output_time; (t1.*p3)( ); return 0;}
10
10:13:56
10:13:56
10:13:56
#include <iostream>#include <string>using namespace std;class Student{public: Student() {} Student( const string& nm, int sc = 0 ): name(nm), score(sc){} //(1)下面的const干神马?nm为常对象,不能改变___________ void set_student( const string& nm, int sc = 0 ) { name = nm; score = sc;} //(2)下面的const分别干神马?__声明常成员函数______ const string& get_name() const { return name;} int get_score() const { return score; }private: string name; int score;};//(3)下面的const干神马?___常引用__________void output_student(const Student& student ){ cout << student.get_name() << "\t"; cout << student.get_score() << endl;}int main(){ Student stu( "Wang", 85 ); output_student( stu ); return 0;}
#include<iostream>using namespace std;class myClass{public: myClass(){ number++;} ~myClass(){ number--;} static int number;};int myClass::number=0;int main(){ myClass *ptr; myClass A,B; myClass *ptr_Arr=new myClass[3]; ptr=ptr_Arr; myClass C; cout<<myClass::number<<endl; delete []ptr; return 0;}
6
0 0
- 阅读程序
- 阅读 程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 程序阅读
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 阅读程序
- 第五周项目三——用多文件组织多个类的程序
- HDU2393 Higher Math【几何】【水题】
- Contest1376 - "师创杯"烟台大学第二届ACM程序设计精英赛复现 A--A Repeating Characters
- android5.0编译问题:No rule to make target 'external/chromium_org/third_party/angle/.git/index',
- 面试题之_00(旋转字符串)
- 阅读程序
- 用多文件组织多个类的程序
- 第五周 项目四-静态成员应用
- 第五周项目一 体验常成员函数
- 快速排序(QuickSort)
- 第五周 项目一 体验常成员函数
- 直接插入排序
- 第5周项目1——体验常成员函数
- 校内互测第三周(East!XXI~East!XXV)总结