标题:开辟空间
取消只看楼主
愿o圆o安
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2017-3-13
结帖率:25%
已结贴  问题点数:20 回复次数:0 
开辟空间
#include<iostream.h>
#include<stdlib.h>
class time
{
private:
    int hour;
    int minute;
    int sec;
public:
    void input(time *p);
    void output(time *p);
};

void time::input(time *p)
{
    cout<<"please enter hour";
    cin>>p->hour;
    cout<<"please enter minute";
    cin>>p->minute;
    cout<<"please enter sec";
    cin>>p->sec;
}

void time::output(time *p)
{
    cout<<p->hour<<":"<<p->minute<<":"<<p->sec<<endl;
}

int main()
{
    time *p;
    p=(time*)malloc(sizeof(int));
    input(p);
    output(p);
    free(p);
    return 0;
}
搜索更多相关主题的帖子: private include public please minute 
2017-03-13 21:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-475043-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028097 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved