Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

goddammit, C++

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:


#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) {}
};

#endif


vertex.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) {}
};

#endif


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.

Name: Anonymous 2009-04-25 11:25

>>16
say hi to bjarne for me.
What is ``bjarne'' and how could you say hi to it if it is not a unique entity?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List