Reputation: 167
I am still wondering why an error message keeps on appearing when trying to declare a vector:
"Unknown type name 'setSize'"
#ifndef INTEGERSET_H
#define INTEGERSET_H
#include <vector>
using namespace std;
class IntegerSet
{
public:
IntegerSet();
IntegerSet(const int [], const int);
IntegerSet & unionOfSets(const IntegerSet &, const IntegerSet &) const;
IntegerSet & intersectionOfSets(const IntegerSet &, const IntegerSet &) const;
void insertElement(int);
void deleteElement(int);
void printSet();
bool isEqualTo(const IntegerSet &);
const int setSize = 10;
vector<bool> set(setSize);
};
#endif
PS : I had to add 4 spaces to every line in order to copy and paste the above code, because it all went out of format. Is there an easier way?
Upvotes: 2
Views: 98
Reputation: 227370
This is parsed as a function declaration:
vector<bool> set(setSize); // function `set`, argument type `setSize`
You need a different initialization syntax:
vector<bool> set = vector<bool>(setSize);
Also note that giving things names such as set
while using namespace std;
is a very bad idea. using namespace std;
is a bad idea in most cases anyway.
Upvotes: 7