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 19:20

>>23
“I liken starting one’s computing career with C++, say as an undergraduate,
to being born in East Africa. It is intolerably hot, your
body is covered with lice and flies, you are malnourished and you
suffer from numerous curable diseases. But, as far as young East
Africans can tell, this is simply the natural condition and they live
within it. By the time they find out differently, it is too late. They
already think that the writing of C++ is a natural act.” - Ken Pier, Xerox PARC

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