3

I am creating a data structure but when I try and compile I get an error saying that I haven't specified that type of set that I am initializing.

I am working with the NTL library with is used for large numbers.

This is my code:

#include <set>
#include ...

NTL_CLIENT

using namespace std;
using namespace NTL;

const RR ZERO = to_RR(0);
const RR ONE = to_RR(1);
const RR TWO = to_RR(2);

class tenTree
{
   public:
      tenTree(string  newName = "", int newLevel = 0);
      ~tenTree();
      void put(string prefix, RR power);
      bool get(string prefix, RR & output);
      void display(int depth);
      bool isKnown(RR power){return (powers.find(power) != powers.end());};
   private:
      tenTree* children [10];
      set<int> powers;
      int level;
      string name;
      bool child[10];
};

When I try to compile it comes back with an error saying:

twoPow.cpp:47: error: ISO C++ forbids declaration of \u2018set\u2019 with no type
twoPow.cpp:47: error: expected \u2018;\u2019 before \u2018<\u2019 token
twoPow.cpp: In member function \u2018bool tenTree::isKnown(NTL::RR)\u2019:
twoPow.cpp:44: error: \u2018powers\u2019 was not declared in this scope

Is there something that I am missing here?

Schuyler
  • 509
  • 1
  • 9
  • 19
  • 2
    I presume this is a header file. Plase **never** do `using namespace ...;` in a header file. – chris Jul 17 '13 at 23:22
  • 4
    Yeah, slap a std:: on there... – jdero Jul 17 '13 at 23:23
  • Unfortunately my school makes us put all of our code in one file. This isn't a header. – Schuyler Jul 17 '13 at 23:27
  • There is an extra `;` after the definition of `bool isKnown(RR power)`, not sure if that matters... –  Jul 17 '13 at 23:27
  • 1
    @SSAdmin what he is saying is dont use "using" instead qualify each type with the namespace like std::string and NTL::RR. Delete the lines using namespace std; using namespace NTL; – madnut Jul 17 '13 at 23:28
  • @RyanMcK, I'm pretty sure it's optional, but I get warnings when I do that. – chris Jul 17 '13 at 23:31

1 Answers1

0

It was just a matter of the scope. All I had to do was add an std:: before the set and it compiled correctly.

Schuyler
  • 509
  • 1
  • 9
  • 19