Welcome! Log In Create A New Profile

Advanced

Assignment 4 Q6

Posted by Sanjiv 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment 4 Q6
July 01, 2006 11:49AM
Hi

I am having problems with declaring a vector in the class declaration. The compiler is giving me the following error:
"vector' is used as a type, but is not defined as a type"

Here is my code:

#include <Vector>

//Class specification
range">template<range">class T>
range">class Set
{
range">public:
//Default Constructor
Set();
//Add a new Element
range">void Add(T t);
//Remove an element
range">void Remove(T t);
//List the elements in the set
range">void List();
//Get the size of the Set
range">int Size();
//Get an element from the set
T Get(int position);
//Intersection of this set with another
Set<T> Intersection(Set<T> s);
//Union of this set with another
Set<T> Union(Set<T> s);
//Difference of this set with another
Set<T> Difference(Set<T> s);

range">private:
//A vector to store the elements of the set
vector<T> vecSet;
};
avatar Re: Assignment 4 Q6
July 04, 2006 05:38PM
Vector is part of the Standard Template Library (STL), which is defined in the namespace std. Just change your private definition to:
range">private:
   // a vector to store the elements of the set
   std::vector<T> vecSet;

Oh, and another thing, Mac, the moderator has added code tags so that programme code can be better shown on the fora (see my code fragment above). To use them just type [ code ] before your code and [ /code ] after. Obviously I put in spaces so you can see what I've typed. Leave the spaces out.
Re: Assignment 4 Q6
July 12, 2006 02:02PM
I am looking for help with question 6 and 7 , but mostly question 6.
If you come right with these question please let me know.

Thanks

Re: Assignment 4 Q6
July 15, 2006 01:58PM
they are rather difficult.
and the text book is a fat load of help (yeh right).

Sorry, only registered users may post in this forum.

Click here to login