[問題] 抓不到錯誤?
遇到的問題: (題意請描述清楚)
小弟在練習一個CLASS的程式中,題意大致為設定時間後以12小時制顯示
但在寫一小部分後,編譯時會出現以下的錯誤
expected primary-expression before "const" 錯誤出現的位置CODE中有標示
"getup" undeclared (first use this function)
開發平台:Dev-C++
#include <iostream>
using namespace std;
class time
{
private:
int hour;
int minute;
int second;
public:
time(int x,int y,int z):hour(x),minute(y),second(z){}
int get_hour()const;
int get_minute()const;
int get_second()const;
void time_24(int,int,int)const;
void time_12(int,int,int)const;
};
int time::get_hour()const
{
return hour;
}
int time::get_minute()const
{
return minute;
}
int time::get_second()const
{
return second;
}
void time::time_24(int now_hour,int now_minute,int now_second)const
{
cout<<now_hour<<":"<<now_minute<<":"<<now_second<<endl;
}
void time::time_12(int now_hour,int now_minute,int now_second)const
{
if(now_hour>12)
{
now_hour = now_hour%12;
cout<<now_hour<<":"<<now_minute<<":"<<now_second<<"PM"<<endl;
}
else
{
cout<<now_hour<<":"<<now_minute<<":"<<now_second<<"AM"<<endl;
}
}
int main()
{
const time* getup=new time(6,45,26); <--錯誤在此行
int x,y,z;
x=getup->get_hour();
y=getup->get_minute();
z=getup->get_second();
getup->time_24(x,y,z);
delete getup;
}
煩請各位幫忙小弟解答
謝謝各位!<(_ _)>
--
您有想清掉的雜物嗎? 太多用不著、丟掉又可惜的東西想找個好歸宿? , ,
穿不下的衣服、用不到的文具、玩具、娃娃、贈品堆太多不知怎處理嗎? ▼
助人最好時機就是現在!!若您有不需要的書籍,雜物 http://0rz.tw/a34O6╰ 愛 ╯***
歡迎來公益版Ptt-Charity給需要的單位,您用不著的東西可能就是他們的寶貝!︽
讓您不需要的東西,給最需要的人珍惜,既清空間又可做好事,一舉數得喔!◢◣◣ ◤
市民廣場->3.PttAction->5.Ptt-Charity 公益版歡迎您一起舉手之勞做公益 ◥◤︶ ◤
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.229.54.97
→
01/21 10:50, , 1F
01/21 10:50, 1F
→
01/21 10:50, , 2F
01/21 10:50, 2F
推
01/21 13:19, , 3F
01/21 13:19, 3F
推
01/21 13:24, , 4F
01/21 13:24, 4F
→
01/21 13:41, , 5F
01/21 13:41, 5F
→
01/21 13:41, , 6F
01/21 13:41, 6F
推
01/21 13:48, , 7F
01/21 13:48, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章