tags:

views:

117

answers:

4

My Node.h is

class Node{
private:
    int x;

    int y;

public:

    Node();

     Node(int x, int y);

    void setXX( int x);
        .....

}

In Node.cpp I am doing:

#include "Node.h"
#include "stdafx.h"

Node:: Node(){}
Node:: Node(int x, int y){
     this->x = x;
     this->y =y;

}

void Node::setXX(int x){
     this->x = x;
}

}

I get the errors for all line :

Error 2 error C2653: 'Node' : is not a class or namespace name Error 3 error C2673: 'setXX' : global functions do not have 'this' pointers

I am using visual studio to compile? Any idea

+1  A: 

add a semicolon to the end of the class Node definition.

Goz
+4  A: 

Couple of things:

(1). Missing semicolon in the header file for the class definition

(2). Extra } in the cpp file.

Resolve these two issues and check whether it solves the problem.

Naveen
+1  A: 

class declaration is missing a semicolon, then there seems to be an excess of closing braces in the very end.

iCE-9
Naveen beat me to it.;)
iCE-9
+3  A: 

I see three problems:

  1. A missing semicolon at the end of your class definition.
  2. A superfluous } at the end of the Node.cpp file.
  3. Code before #include "stdafx.h"

I suspect the first two to be errors you introduced while writing your question (always cut and paste real code) and the latter to be the problem:

In Visual C++, when you're using pre-compiled headers (or in some PCH scenarios anyway - I never used PCHs myself, so I wouldn't know), the compiler replaces everything from the beginning of a translation unit up to #include "stdafx.h" with the content of the (corresponding) pre-compiled header. So there shouldn't be anything before #include "stdafx.h".

sbi