向量之前的期望类型说明符

时间:2015-01-16 14:37:35

标签: c++ vector

我之前看到过与此错误相关的问题,但我没有解决我的问题。我评论了可能产生同样错误的行。这里s the code I使用 在文件path.h中

#ifndef PATH_H
#define PATH_H                         //same PATH_H for ifndef and define

#include <vector>
class face{
std::vector<unsigned int>face_index;   //std namespace is used for vector
std::vector<vector3d>face_vertex;      //to avoid conflict
std::vector<vector3d>midpoint;         //vector3d is a class
public:
face(std::vector<unsigned int>*fid, std::vector<vector3d>*fv, std::vector<vector3d>*mid)
    {
    face_index = *fid;    //to assign values
    face_vertex = *fv;
    midpoint = *mid;
    }

};


class path{
std::vector<face*>faces;          //pointer used
std::vector<vector3d> path_verts;
public:
publicfunc();
~path();                          //destructor used
};
#endif

在文件path.cpp中,

#include "path.h"                 //header file used

void path::publicfunc()
{
std::vector<unsigned int>face_i;     //for face_index
std::vector<vector3d>face_v;         //for face_vertices
std::vector<vector3d>midp;           //for midpoint

unsigned int f_index[3];
vector3d f_vertex[3];

    for(unsigned int i = 0; i < meshV->mNumVertices; i++)
    {
    const aiVector3D* pPos = &(meshV->mVertices[i]);
    path_verts.push_back(vector3d(pPos->x, pPos->y, pPos->z));    
    }             
                                     //path_verts has stored vertices now


    for(unsigned int i=0; i<meshV->mNumFaces; i++)
    {
    face_i.push_back(i);                         //push back unsigned int
    vector3d mid;
    aiFace face=meshV->mFaces[i];
    for(int j=0;j<face.mNumIndices;j++) //0..2
    {
        f_index[j] = face.mIndices[j];
        f_vertex[j] = path_verts[f_index[j]];   //get verts using indices
        face_v.push_back(f_vertex[j]);            //push back vector3d
    }
    mid/=3;                                       //median of triangle
    midp.push_back(mid);                         //push back median
    faces.push_back(new face(&face_i, &face_v, &midp));  //error line
    }                   

}


path::~path()
{
for(int i = 0; i<faces.size(); i++)
    {
    delete faces[i];                        //free memory
    }
}

显示的错误是face之前的预期类型说明符。 它所谈论的face是新的&#39;之后的那个。

0 个答案:

没有答案