[英]does not name a type error c++
我將代碼分為兩個文件,如下所示。 這是頭文件graph.h
//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
。 我不明白為什么會這樣。 任何幫助表示贊賞。
源代碼的第一行。
#ifdef GRAPH_H
應該
#ifndef GRAPH_H
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.