2013-03-04 75 views
-2

我使用以下指南http://rodrigo-silveira.com/opengl-tutorial-parsing-obj-file-blender/#.UTRmkvUudqI矢量:类模板的参数列表:“的std ::矢量缺少”

,因为我试图加载在WebGL的OBJ文件。 在我的RokkoParse.cpp文件中,我使用'vector'。 但我的编译器说“std :: vector丢失”我试图在网络上搜索这个错误,但我无法找到任何好的东西。 有人可以帮我解决我的问题吗?

RokkoParses.h

#pragma once 
#include <vector> 
#include <string> 
#include <iostream> 
#include <string> 

using std::string; 

class RokkoParser 
{ 
public: 

public: 
    static void objToTxt(const string aInFilename, 
         const string aOutFilename, 
         bool aVerbose = false); 
    static std::vector explode(string aStr, char aDelim); 
}; 

RokkoParser.cpp

#include "StdAfx.h" 
#include "RokkoParser.h" 
#include <cstdio> // instead of <stdio.h> 
// #include <conio.h> -- do not use 
#include <cstring> // instead of <string.h> 
#include "stdafx.h" 
#include <iostream> 
#include "stdafx.h" 
#include<iostream> 
#include<conio.h> 
#include <string> 
#include <iostream> 
#include <vector> 
#include <string> 
#include <iostream> 
#include <string> 

using namespace std; 


vector RokkoParser::explode(string aStr, char aDelim) 
{ 
    vector res; 
    string str = aStr.substr(0, aStr.find(aDelim)); 

    while(str.size() < aStr.size()) 
    { 
    res.push_back(str); 
    aStr = aStr.substr(aStr.find(aDelim) + 1); 
    str = aStr.substr(0, aStr.find(aDelim)); 
    } 

    res.push_back(str); 

    return res; 
} 

在这两个文件,他们说了同样的错误

谢谢!

+0

std :: vector不是一个类型。它是你必须提供参数以使其输入的模板。 – 2013-03-04 10:16:17

回答

3

vector是一类模板。当你声明一个向量时,你必须指定向量元素应该具有的类型:“什么”的向量

例如:

std::vector<int> vi;   // This declares a vector of integers 
std::vector<std::string> vs; // This declares a vector of strings 
// ... 

在代码中,您使用std::vector没有任何模板参数。这就是编译器抱怨的原因。

2

我敢肯定,你没有给我们完整的错误信息,它实际上说“std :: vector缺少类型参数”或类似的东西。

原因是vector是一个类模板,你必须告诉它你希望它容纳什么样的对象, vector<int>vector<string>