我收到cpp编译器的警告,我似乎无法解决.我想至少明白我做错了什么......
sketch\IRectangle.h:7:20:警告:ISO C++禁止声明'Rectangle'没有类型[-fpermissive]
矩形(INT,INT);
Run Code Online (Sandbox Code Playgroud)^
头文件
#ifndef RECTANGLE_H
#define RECTANGLE_H
class IRectangle
{
public:
Rectangle(int,int);
void set_values (int,int);
int area (void);
private:
int width, height;
};
#endif
Run Code Online (Sandbox Code Playgroud)
Rectangle实现
#include "IRectangle.h"
IRectangle::Rectangle(int width, int height)
{
}
void IRectangle::set_values (int a,int b)
{
}
int IRectangle::area()
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
谷歌搜索后,我遇到了这个和这个线程,但我三重检查原型是否匹配,所以我真的无法弄清楚我做错了什么.
PS:在C++中用"I"加前缀接口是否可以?