1
我在下面列出了我的代碼。我得到很多錯誤,說cout和endl沒有在這個範圍內聲明。我不知道自己做錯了什麼,或者如何強迫班級認出cout?我希望我正確地解釋我的問題。如果我註釋掉這些方法(不是構造函數),它就可以工作。我可能只是在這裏犯新手錯誤 - 請幫忙。Cout和endl錯誤
using namespace std;
class SignatureDemo{
public:
SignatureDemo (int val):m_Val(val){}
void demo(int n){
cout<<++m_Val<<"\tdemo(int)"<<endl;
}
void demo(int n)const{
cout<<m_Val<<"\tdemo(int) const"<<endl;
}
void demo(short s){
cout<<++m_Val<<"\tdemo(short)"<<endl;
}
void demo(float f){
cout<<++m_Val<<"\tdemo(float)"<<endl;
}
void demo(float f) const{
cout<<m_Val<<"\tdemo(float) const"<<endl;
}
void demo(double d){
cout<<++m_Val<<"\tdemo(double)"<<endl;
}
private:
int m_Val;
};
int main()
{
SignatureDemo sd(5);
return 0;
}
已包含頭? –
如果你已經包含頭文件,你寫了'using namespace std;'? –
guneykayim
這與Qt或OOP無關,因此編輯。 –