使用字符串时,C++未知重写说明符
C++ unknown override specifier when using strings
我已经尝试解决这个问题很长时间了:
我有以下课程(医生):
医生:
#pragma once
class Doctor
{
private:
string firstName;
public:
Doctor();
~Doctor();
};
博士.cpp:
#include "stdafx.h"
#include "string"
#include "Doctor.h"
using namespace std;
Doctor::Doctor()
{
}
Doctor::~Doctor()
{
}
以及我的主要功能:
#include "stdafx.h"
#include <string>
#include "Doctor.h"
using namespace std;
int main()
{
return 0;
}
错误C3646"firstName":未知的重写说明符
错误C4430缺少类型说明符-假定为int。注意:C++不支持默认的int
错误C3646"firstName":未知的重写说明符
错误C4430缺少类型说明符-假定为int。注意:C++不支持默认的int
在Doctor.h的第5行,我声明了一个字符串变量
也许
<string> header is missing.
尝试包含它。
Dr.h
#ifndef DOCTOR_H_
#define DOCTOR_H_
#include <string>
class Doctor{
std::string name;
public:
Doctor();
~Doctor();
};
#endif
博士.cpp
#include "Doctor.h"
Doctor::Doctor()
{
}
Doctor::~Doctor()
{
}
主要.cpp
#include "Doctor.h"
int main()
{
return 0;
}
它运行良好。我已经测试过了。
您需要Doctor.h
中的#include <string>
,并且需要标准命名空间std::string
。
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 继承期间显示未知行为的子类
- 将OpenCV C++重写为EmguCV C#-如何使用指针
- 输入中的字符串数未知(以字母表示)
- 具有未知值时的时间复杂性
- 在 C++ 中用派生类型重写成员函数
- 在模板基类中为继承类中的可选重写生成虚拟方法
- 链表中写入访问冲突的未知原因
- 正在生成未知类实例
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- 方法重写线程C++中的概念
- 读取文件时运行时的未知行为
- 代码在我的计算机上运行良好,但是在将其提交给coursera时遇到未知的信号11问题
- 为重写std::exception的库生成swig接口时出错
- 初始化多个未知基类
- 如何强制从重写方法调用重写的方法基方法?
- 用于C++的静态二进制检测或二进制重写工具和框架
- 在回调中使用函数时,C++未知重写说明符
- VisualC++ 编译器错误 C3646:未知的重写说明符
- 使用字符串时,C++未知重写说明符