Re: [問題] 計程class問題
※ 引述《jackwei (吐司)》之銘言:
: employee worker1("Paul","Lin",30000); //parameter是constructor要求輸入的
: //現在想測試一下initial的資料
: cout<<"The employee "<<worker1.getfirstname()<<" "
: <<worker1.getlastname()<<"\'s monthly salary is "
: <<worker1.getmonsalary()<<endl;
: 結果compile的時候他告訴我這邊錯了(cout那行)
: 以下是錯誤訊息
: no match for 'operator<<' in 'std::operator<<
: [with _Traits = std::char_traits<char>]
: (((std::basic_ostream<char, std::char_traits<char> >&)(&std::cout)),
: ((const char*)"The employee ")) << (&worker1)->employee::getfirstname()'
: 看不懂- -a
: 有高手能幫忙解惑嗎
: 謝謝
class employee
{
public:
employee(string name1,string name2,int sry)
{fstname=name1;
lstname=name2;
monsry=sry;}
void set()
{
cout<<"Please enter the employee's first name:";
getline(cin,fstname);
cout<<"Please enter the employee's last name";
getline(cin,lstname);
cout<<"Please enter the empolyee's monthly salary;";
cin>>monsrytemp;
if(monsrytemp>=0)monsry=monsrytemp;
else monsry=0;
}
void getfirstname()
{
cout<<fstname;}
void getlastname()
{
cout<<lstname;}
void getmonsalary()
{
cout<<monsry;}
private:
string fstname,lstname;
int monsry,monsrytemp;
};
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.240.124
※ 編輯: jackwei 來自: 140.112.240.124 (11/11 22:49)
推
11/11 22:52, , 1F
11/11 22:52, 1F
推
11/11 22:54, , 2F
11/11 22:54, 2F
推
11/11 22:59, , 3F
11/11 22:59, 3F
→
11/11 23:01, , 4F
11/11 23:01, 4F
推
11/11 23:03, , 5F
11/11 23:03, 5F
推
11/12 01:17, , 6F
11/12 01:17, 6F
討論串 (同標題文章)