Name: Anonymous 2009-04-24 18:28
Hey, /prog/. I have encountered a frustrating problem in my project. I've stripped my code down to the bare essentials and I still don't know why this is fucking up.
main.cpp:
edge.h:
vertex.h:
Errors:
Error 1 error C2146: syntax error : missing ';' before identifier 'v'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
So, can anyone tell me what ridiculously stupid thing I'm doing and/or ridiculously simple thing I'm missing? This is driving me nuts.
main.cpp:
#include <iostream>
#include "vertex.h"
#include "edge.h"
using namespace std;
int main()
{
Vertex v;
Edge e;
cout << "It works." << endl; //lol, no.
}edge.h:
#ifndef Edge_h
#define Edge_h
#include "vertex.h"
class Edge
{
public:
int label;
Vertex v; // This line does not compile. edge.h does not know what a vertex is.
Edge() : label(1) {}
};
#endifvertex.h:
#ifndef Vertex_h
#define Vertex_h
#include "edge.h"
class Vertex
{
public:
int label;
Edge e; // This line compiles just fine. vertex.h knows what an Edge is.
Vertex() : label(1) {}
};
#endifErrors:
Error 1 error C2146: syntax error : missing ';' before identifier 'v'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
So, can anyone tell me what ridiculously stupid thing I'm doing and/or ridiculously simple thing I'm missing? This is driving me nuts.