hmp54
hmp54

Reputation: 43

error: ‘nullptr’ was not declared in this scope

I'm trying to compile a project on my university's ssh server and I get the error:

Node.h:12: error: ‘nullptr’ was not declared in this scope

Chunk of code from my Node.h class:

template <typename T> 

struct Node{
    T data; 
    Node *leftChild; 
    Node *rightChild; 

    Node(const T & theData = nullptr, Node *left = nullptr, Node *right = nullptr);
    Node(T && theElement = nullptr, Node *left = nullptr, Node *right = nullptr);

    T getData(); 
}; 

The server runs on GCC version 4.4.7 and I'm compiling using the following command:

g++ -std=c++0x

^ I use this command for all of my projects for this class, and this is the first time I'm running into this issue. What can I try to resolve this?

Upvotes: 3

Views: 3599

Answers (1)

Aroic
Aroic

Reputation: 479

According to https://gcc.gnu.org/projects/cxx-status.html#cxx11, the null pointer constant is a part of GCC 4.6+. You'll have to find a way around using the nullptr constant or update the GCC version(recommended).

Upvotes: 3

Related Questions