c++ - 对象 vector 无法编译

标签 c++ class types vector

我已经将 vector 与对象一起使用了数百次,但现在似乎它不想对它们做任何事情。我不断收到编译错误“模板类型参数的模板参数必须是类型”:

注意我正在使用开放框架

#pragma once

#include "ofMain.h"
#include "cLine.h"

using namespace std;

class testApp : public ofBaseApp{
    public:

        vector < cLine > lines; // Here is the vector of type cLine

        void setup();
        void update();
        void draw();

        void keyPressed(int key);
        void keyReleased(int key);
        void mouseMoved(int x, int y);
        void mouseDragged(int x, int y, int button);
        void mousePressed(int x, int y, int button);
        void mouseReleased(int x, int y, int button);
        void windowResized(int w, int h);
        void dragEvent(ofDragInfo dragInfo);
        void gotMessage(ofMessage msg);
};

以及 cLine 的头文件:

#ifndef aftermotion_cLine_h
#define aftermotion_cLine_h

#include <iostream>
#include "ofMain.h"

class cLine
{
public:

    int y;
    float thickness;

    cLine();
    cLine(const cLine &);
    cLine(float thinkness);

    void draw();
    void update();

};

#endif

编辑:我已经尝试过 #include ,它没有改变任何事情,因为它已经是 sdt 库的一部分,该库本身包含在来自开放框架库的“ofMain.h”文件中

最佳答案

你永远不会#include <vector>在你的标题中。因此,std::vector不是已知类型。

关于c++ - 对象 vector 无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12682792/

相关文章:

java - 如何引用 Java 中使用通配符标识的类的类?

c++ - 使用 Blackbone 读取进程内存?

c++ - 计算区间内数字频率的类

c++ - 传递类成员的函数指针

c++ - 编写构造函数/析构函数是好的做法吗?

c++ - 使用运算符读取 .CSV 文件 >>

c++ - 如果 Y 值为 1,即使 X 值为 0,sf::Vector2i 作为 std::map 中的键显示为 (1, 1)

node.js - 如何访问模块中的 TypeScript 定义?

entity-framework - Entity Framework : Value cannot be null. 参数名称:类型

c# - 通过反射获取简单类型的用户友好名称?