0

I am trying to set initializes for my constructor but I am getting an error saying that nullptr and NULL are both not in scope. I have looked around and saw that I needed to add #include cstddef but I am still getting the same error.

template<class ItemType>
class BinaryNode
{
private:
   ItemType                              item;          // Data portion
   BinaryNode<ItemType> * leftChildPtr;  // Pointer to left child
   BinaryNode<ItemType> * rightChildPtr; // Pointer to right child

public:
   BinaryNode();
};


#include "BinaryNode.h"
#include <cstddef>

template<class ItemType>
BinaryNode<ItemType>::BinaryNode() : leftChildPtr(nullptr) , rightChildPtr(nullptr)
{
} // end Constructor 
Andres
  • 13
  • 2
  • 4
    Does your compiler support C++11? – Kerrek SB Nov 21 '16 at 23:46
  • 1
    Please put your code in a code block and ensure it is a MVCE (http://stackoverflow.com/help/mcve). – Nicholas Smith Nov 21 '16 at 23:47
  • I have fixed the code blocks and how do i check if it suppots c++11? – Andres Nov 21 '16 at 23:48
  • @AJacinto [that's an old question](http://stackoverflow.com/questions/5047971/how-do-i-check-for-c11-support). – Drew Dormann Nov 21 '16 at 23:51
  • @DrewDormann I do have the latest Ubuntu install and I have read that it comes with it by default. – Andres Nov 21 '16 at 23:54
  • @AJacinto So you do gcc -v: if it is >= 5, you got everything you need. just compile with -std=c++11. – zeralight Nov 21 '16 at 23:58
  • @HédiGhédiri So i have compiled my .cpp file with -std=c++11 and I am now getting this error /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' – Andres Nov 22 '16 at 00:12
  • 1
    @AJacinto That's a completely different, unrelated question to the above. – MrEricSir Nov 22 '16 at 00:31
  • Well you compiled and linked cpp files when the none of them had the main function(). I think you used to compile with an IDE ? If so please check the compiler options for the IDE and add the -std=c++11. If you're using the command line, then consider g++ -o output_name -std=c++11 *.cpp or something similar. – zeralight Nov 22 '16 at 00:32
  • Add the following 3 lines to your file ´#if __cplusplus < 201103 #error this is no C++11 #endif´ – Surt Nov 22 '16 at 06:37

0 Answers0