2013-05-27 7 views
0

Я выделил код в двух файлах, как показано ниже. Вот файл заголовка graph.hне называет ошибку типа C++

//graph.h 
#ifdef GRAPH_H 
#define GRAPH_H 

#include <vector> 
#include <fstream> 

#include "kernel_def.h" 

using namespace std; 

typedef vector<bool> Array; 
typedef vector<Array> TwoDArray; 

class baseGraph { 
    private: 
     int nodes; /*Number of nodes.*/ 
     vector<feature_vector *> vec; /*vector of feature nector.*/ 
    public: 
     baseGraph(int nodes); 
     /*set-get functions*/ 
     int getNodes(); 
     void setNodes(int nodes); 
     const feature_vector *getVec(int pos); 
     int setVec(int pos, feature_vector *fVec); 

     /*Input edges from file and set up in corresponding representation.*/ 
     virtual void setGraph(ifstream &ipf) = 0; 

     /*Utility functions*/ 
     virtual void printGraph() = 0; 
     virtual feature_vector *subgraph_d(int node, int depth) = 0; /*subgraph upto depth d.*/ 
}; 

Здесь graph.cpp

//graph.cpp 
#include <iostream> 

#include "graph.h" 

using namespace std; 

baseGraph::baseGraph(int nodes) { 
    setNodes(nodes); 
    /*feature vetors will be assigned later.*/ 
    vec.resize(nodes); 
    for(int i=0;i<nodes; ++i) 
     vec.at(i) = NULL; 
} 

При компиляции я получаю ошибку, что src/graph.cpp:7:1: error: ‘baseGraph’ does not name a type. Я не понимаю, почему это происходит. Любая помощь оценивается.

+0

Взгляните еще раз на ваш включать охранников в graph.h. –

+0

Yup. Понял. Эта вещь меня расстраивала. –

+0

Используйте '#pragma once' вместо охранников. – kfsone

ответ

5

Первая линия источника.

#ifdef GRAPH_H 

должен быть

#ifndef GRAPH_H 
Смежные вопросы