ISO C++禁止在没有类型的情况下声明"..."

bas*_*bas -1 c++

我收到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"加前缀接口是否可以?

Bri*_*ian 7

构造函数必须与类具有相同的名称.如果该类已命名IRectangle,则必须命名构造函数IRectangle.