[英]error: prototype for 'EM::EM(…)' does not match any in class 'EM'
在我在.h 文件中聲明 class 並且正在工作之后,我添加了一些函數和庫,然后出現了這個錯誤!
(錯誤:'EMPLOYE::EMPLOYE(std::string, int, int)' 的原型與 class 'EMPLOYE' 中的任何一個都不匹配)
這是兩個文件
PRJET.h
#ifndef PRJET_h
#define PRJET_h
#include <iostream>
#include <string>
using namespace std;
class EMPLOYE{
protected:
string nom;
int matricule,indice;
static int valeur ;
public:
Employe(string , int, int);
void afficher();
int salaire();
};
class RESPONSABLE : public EMPLOYE{
protected:
EMPLOYE SUBORDONE[];
string responsable;
public:
Responsable(string,string,int,EMPLOYE[],string);
//bool verifierEmploye(int){};
//void ajouterEmploye(Employe){};
//void afficheEmploye(){};
};
#endif // date_H
PRJET.cpp
#include <iostream>
#include "PRJET.h"
#include <string>
using namespace std;
EMPLOYE::EMPLOYE(string n , int m ,int i){
nom=n;
matricule=m;
indice=i;
}
C++ 區分大小寫。
名稱EMPLOYE
和名稱Employe
是兩個不同的名稱。
因此,您實際上並沒有為EMPLOYE
聲明構造函數,從而使編譯器感到困惑。
您的 class 沒有用戶定義的構造函數,應該是這樣的:
class EMPLOYE{
protected:
string nom;
int matricule,indice;
static int valeur ;
public:
EMPLOYE(string , int, int);
void afficher();
int salaire();
};
PS:類型名稱全部大寫是非常奇怪的,這違反了語言約定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.