- 论坛徽章:
- 0
|
1 #include<iostream>
2 using namespace std;
3 class time
4 {
5 public:
6 time(int,int,int);
7 void display();
8 private:
9 int hour;
10 int minu;
11 int sec;
12 };
13 time::time(int h,int m,int s)
14 {
15 hour=h;
16 minu=m;
17 sec=s;
18 }
19 void time::display()
20 {
21 cout<<hour<<":"<<minu<<":"<<sec<<endl;
22 }
23 int main()
24 {
25 time t1(10,25,36);
26 t1.display();
27 return 0;
28 }
sun.cpp: 在函数‘int main()’中:
sun.cpp:25:7: 错误: expected ‘;’ before ‘t1’
sun.cpp:26:3: 错误: ‘t1’在此作用域中尚未声明
在vc中运行正常 但g++就报错。为什么?? |
|