0

someone passed me an openFrameworks project src folder. The project has a class called "rectangle."

Inside the src folder there are main.h, testApp.cpp, testApp.h, rectangle.cpp, rectangle.h. I directly replace the src folder in my empty project, but the project won't compile.

I believe the search directories are right since the class files are also in the src folder.

However CB shows me the "error: Rectangle does not name a type" in testApp.h

 Rectangle myRect;

I already included the header files in testApp.h (#include "rectangle.h") and have the rectangle.h include ofMain.h

Not sure if I am doing the right way to include a class.

Thanks!

The testApp.h file:

enter image description here

The rectangle.h file:

enter image description here

The rectangle cpp:

enter image description here

file structure:

enter image description here

4

1 回答 1

0

你没有提供足够的信息,所以这都是猜测。然而,我的猜测是,几乎看不见ofBa...的才是罪魁祸首!如果此类碰巧有一个名为 的函数Rectangle,则会找到此名称,并且它显然不是类型。这是您应该发布的简短示例,演示了问题:

class Rectangle
{
};

struct foo
{
    void Rectangle() {}
};

struct bar
    : foo
{
    Rectangle r;
};

该问题的一种解决方法是使用::Rectangle而不是,Rectangle因为此限定会强制在全局范围内进行查找。

于 2013-08-29T22:07:41.400 回答