一个C++程序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一个C++程序相关的知识,希望对你有一定的参考价值。

#include<iostream>
using namespace std;
class Time
{public:
int hour;
int minute;
int sec;
};

int main()
{
void set_time(Time&);
void show_time(Time&);
Time t1;
set_time(t1);
show_time(t1);
Time t2;
set_time(t2);
show_time(t2);
return 0;
}

void set_time(Time& t)
{
cin>>t.hour;
cin>>t.minute;
cin>>t.sec;
}

void show_time(Time& t)
{
cout<<t.hour<<":"<<t.minute<<":"<<t.sec<<endl;
}
技术分享图片

以上是关于一个C++程序的主要内容,如果未能解决你的问题,请参考以下文章

如何使用另一个 C++ 程序编译 C++ 代码?

开启 C++ 生活 -- 第一个 C++ 程序

从 C++ 程序运行 python 程序?

python 调用c++程序, c++程序如何返回数组给python

《好学的C++ 第2版》 第1章 第一个c++程序

如何将本机 C++ 静态库链接到托管 C++ 程序集