2013-11-26 39 views
-2

這是我的課employeeException函數定義不聲明參數簡單的C++程序

#include <iostream> 
#include <string> 

using namespace std; 

class employeeException 
{ 
    public: 
    employeeException(string); 
    void printmessage(); 

    private: 
    string message; 
}; 

int main() 
{ 
    employeeException("Heelo"); 
} 

employeeException::employeeException(string message) 
{ 
    this->message = message; 
} 

void employeeException:printmessage() 
{ 
    cout<<endl 
     <<this->message 
     <<endl; 
} 

對於一些未知的原因,我在編譯過程中出現此錯誤

函數定義不聲明參數

我不明白這個簡單的程序有什麼問題。當然,我錯過了一些簡單的東西。

+1

雙冒號),不值得回答。 – ScarletAmaranth

+0

*「我無法弄清楚什麼是錯的」*爲什麼不呢?您是否仔細閱讀了錯誤消息中提到的代碼行,*逐個字符*? – abelenky

回答

6
void employeeException:printmessage() 
        ^- missing a colon 
{ 
    cout<<endl 
     <<this->message 
     <<endl; 
} 
+1

(不要高興這^^。) – ScarletAmaranth

+3

+1在你的臉! –

0

爲什麼你對這個功能有::

employeeException::employeeException(string message) 

但不是在這一個? (在你只有一個:):在printmessage前(

void employeeException:printmessage()