C++ 类实现文件中未声明的标识符

C++ 类实现文件中未声明的标识符,c++,class,implementation,C++,Class,Implementation,Plorg.h: #include <string> #ifndef PLORG_H #define PLORG_H class Plorg{ private: string name; int CI; public: Plorg(); Plorg(const string & n,int x=50); ~Plorg(); void ChangeID(int CIaux); void Report()

Plorg.h:

#include <string>
    #ifndef PLORG_H
    #define PLORG_H

class Plorg{
private:
    string name;
    int CI;

public:
    Plorg();
    Plorg(const string & n,int x=50);
    ~Plorg();
    void ChangeID(int CIaux);
    void Report() const;
};  
#endif PLORG_H
#包括
#伊芬德夫·普洛古H
#定义PLORG_H
普洛格班{
私人:
字符串名;
int CI;
公众:
Plorg();
Plorg(常量字符串&n,整数x=50);
~Plorg();
无效变更ID(内部变更);
无效报告()常量;
};  
#恩迪夫·普洛古
Plorg.cpp:

#include <iostream>
#include <string>
#include "Plorg.h"

using namespace std;
Plorg::Plorg(){
    name="Plorga";
    CI=50;
};

Plorg::Plorg(const string & n,int CIaux=50){
    name=n;
    CI=CIaux;
};
void Plorg::ChangeID(int CIaux){
    CI=CIaux;
};

void Plorg::Report() const {
    cout << "My name is " << name << "!" <<endl;
    cout << "MY CI is" << CI << "." ;
};

Plorg::~Plorg(){
    cout << "Bye,human" ;
};
#包括
#包括
#包括“Plorg.h”
使用名称空间std;
Plorg::Plorg(){
name=“Plorga”;
CI=50;
};
Plorg::Plorg(常量字符串&n,int-CIaux=50){
name=n;
CI=CIaux;
};
void Plorg::ChangeID(int CIaux){
CI=CIaux;
};
void Plorg::Report()常量{

cout
string
实际上是
std::string

class Plorg{
private:
    std::string name;
//  ^^^
public:
    Plorg();
    Plorg(const std::string& n, int x=50);
//              ^^^
另一方面,您应该支持构造函数初始化列表,不要将默认参数值放在实现中:

Plorg::Plorg(const std::string & n, int CIaux) : name(n), CI(CIAux) {}

您应该使用构造函数初始值设定项列表。我也不认为这是您的第一个错误。您的成员在“Plorg.h”中都缺少
std::
名称空间限定符。不要将
using namespace std;
放在标题中。修复成员和构造函数参数变量声明。谢谢,像你这样的人能抽出时间回答像我这样的人的问题,我仍然感到很惊讶。你真了不起。