小编use*_*172的帖子

object作为函数参数

我写了一个简单的程序.

我收到此错误:

time.cpp: In function ‘int main()’:
time.cpp:22:9: error: expected ‘;’ before ‘a’
time.cpp:23:4: error: ‘a’ was not declared in this scope
time.cpp:24:4: error: ‘b’ was not declared in this scope
time.cpp:25:4: error: ‘c’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

#include<iostream>
using namespace std;
class time
{
    int hour;
    int min;

public:
    void gettime(int h,int m)
    {
        hour=h;
        min=m;
    }

    void puttime()
    {
        cout<<hour<<endl<<min;
    }

    void sum(time x,time y)
    {
        min=x.min+y.min;
        hour=min/60;
        min=min%60;
        hour=hour+x.hour+y.hour;
    }
};

int main()
{ …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
588
查看次数

标签 统计

c++ ×1