错误C2146和错误C44 30 Visual Studio 2013 C++
我试图实现一些从一个主类派生的类,但是我不断得到这些错误,我不知道它们来自哪里。 以下是错误: 错误1错误C4430:缺少类型说明符-假定为int。注意:C++不支持默认INT/P> 错误6错误C2146:语法错误:缺少“,”在标识符“filtername”之前 代码如下: 过滤器H:错误C2146和错误C44 30 Visual Studio 2013 C++,c++,C++,我试图实现一些从一个主类派生的类,但是我不断得到这些错误,我不知道它们来自哪里。 以下是错误: 错误1错误C4430:缺少类型说明符-假定为int。注意:C++不支持默认INT/P> 错误6错误C2146:语法错误:缺少“,”在标识符“filtername”之前 代码如下: 过滤器H: #ifndef _FILTER_H_ #define _FILTER_H_ #include <iostream> #include <string> #include "Image.
#ifndef _FILTER_H_
#define _FILTER_H_
#include <iostream>
#include <string>
#include "Image.h"
class Filter
{
public:
Filter();
~Filter();
virtual bool apply(Image& img, const string filtername);
};
#endif /*FILTER_H_*/
图h:
#ifndef __Image_H__
#define __Image_H__
enum ImageType
{
ImageType_TYPE_RGB8,
ImageType_TYPE_RGB24,
ImageType_TYPE_RGB32
};
class Image
{
public:
int width, height;
ImageType type;
unsigned char* data;
unsigned int size;
Image();
~Image();
};
#endif
该错误与行虚拟bool applyImage&img、常量字符串过滤器名称有关;在filter.h文件中。这是一个猜测,因为我没有看到您的错误消息或包含这些标题的文件
在线虚拟bool applyImage&img,常量字符串过滤器名称;在filter.h中,字符串是否在范围内?我假设您指的是std::string,因为您包括,但不将其导入当前名称空间。尝试用std::string替换字符串。即使对于经常使用VS的人来说,这些数字本身也是毫无用处的。错误描述为:错误2错误C2146:语法错误:缺少“,”标识符“filtername”之前的错误1错误C4430:缺少类型说明符-假定为int。注意:C++不支持缺省INT抱歉,因为缺少INFFEDE您的问题提供错误文本和行数。πάνταῥεῖ 我甚至会删除const,或者传递推荐信。谢谢你的回复!它解决了我遇到的两个错误,但创建了另一个错误:错误1错误LNK2001:未解决的外部符号公共:虚拟bool\uu thiscall Filter::applyclass Image&,class std::basic\u string?apply@Filter@@阿联酋图片@@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@Z谢谢你的帮助。需要其他文件吗?这是链接器错误。Filter::apply是如何定义的?Filter::apply是在FilterGreen.cpp bool FilterGreen::applyImage&img,const std::string filtername{for unsigned int f=1;f
#ifndef __Image_H__
#define __Image_H__
enum ImageType
{
ImageType_TYPE_RGB8,
ImageType_TYPE_RGB24,
ImageType_TYPE_RGB32
};
class Image
{
public:
int width, height;
ImageType type;
unsigned char* data;
unsigned int size;
Image();
~Image();
};
#endif