0

我有一个非常奇怪的问题......首先,这是我班级的文件:

显示.h:

#ifndef SHOW
#define SHOW

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

class Show
{
private:
    std::string m_time;
    int m_serial
public:
    Show(const std::string &time, const int &serial);
    ~Show();
};
#endif

显示.c:

#include "Show.h"

Show::Show(const std::string &time,const int &serial)
{

}

正如你可能看到的,我只写了构造函数的声明,当visual studio在Show.c文件中的第二个“Show”字下划线时,告诉我:

"void Show::Show(const std::string &time,const int &serial)

显示::显示()

显示::显示(常量显示 &)

错误:没有重载函数“Show::Show”的实例与特定类型匹配”

当我将鼠标光标停留在 Show.h 文件中的构造函数上时,看起来该函数不存在......我以前用 C++ 编写过一些类,这是第一次发生类似的事情我...请帮助:(

4

1 回答 1

2

你忘了把字段变量放在;后面。m_serial我相信这是您遇到问题的原因。不幸的是,许多编译器没有给出此类问题的确切原因,因此您必须小心语法规则。

于 2013-04-06T11:08:25.567 回答