C ++在课堂上添加标题会让我感到害怕

时间:2015-07-11 18:42:37

标签: c++

我要将另一个类文件包含到我的.h文件中,但它一直给我一些奇怪的错误。

它没有拿起vector课程。我在线上提到了错误。它说vector is not a Template。我还尝试将<vector>库包含在.cpp文件中,但它无效。

我的MidPointRelations.cpp:

#include "stdafx.h"
#include "MidPointRelations.h"

MidPointRelations::MidPointRelations()
{

}


MidPointRelations::~MidPointRelations()
{

}



MidPointRelations::MidPointRelations(MyLines line, float midpointdis, float aspect)
{
    mylinesss.push_back(line);
    midpointDistance = midpointdis;
    aspectratio = aspect;
}

float MidPointRelations::getAspectRatio(){ return aspectratio; }
void MidPointRelations::Add(MyLines line)
{
    mylinesss.push_back(line);
};

vector<MyLines> MidPointRelations::getLines()  //<<----- error
{
    return mylinesss; 
}

float getMidPointDistance() 
{
    return midpointDistance; 
}

我的MidPointRelations.h:

#pragma once
#include "MyLines.h"
#include <vector>
class MidPointRelations
{
private:
    std::vector<MyLines> mylinesss;
    float midpointDistance;
    float aspectratio;

public:
    MidPointRelations(MyLines line, float midpointdis, float aspect);
    MidPointRelations();
    ~MidPointRelations();
    float getAspectRatio();
    void Add(MyLines line);
    std::vector<MyLines> getLines();
    float getMidPointDistance();
};

1 个答案:

答案 0 :(得分:2)

简单的拼写错误:用std :: vector

替换vector

您可以编写'使用std :: vector',甚至'使用命名空间std',然后只使用vector,但这会导致命名空间污染。我当然建议你不要在标题中这样做。