Class 的基本使用

类类似于声明结构体
对象类似于声明变量

#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
///////////////////////////// 
class TIME
{
    public:
        int h,m,s;
        void showtime(TIME &t)
        {
            cout<<t.h<<":"<<t.m<<":"<<t.s<<endl;
        }
};
/////////////////////////////
void settime(TIME &t,int h,int m,int s)
{
    t.h=h,t.m=m,t.s=s;
}

/////////////////////////////
int main()
{
    TIME t1;
    settime(t1,12,34,32);
    t1.showtime(t1);
}

关于关键字template(模板)
https://blog.csdn.net/biu__biu_biu/article...

本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!