i have a problem regarding classes . i have been given two files vector.h and set.h
the vector.h file is :

#ifndef VECTOR_H
#define VECTOR_H


class vector{
private:
    int *array;
    int max_size; //max size of vector
    int elements; //total element in vector
public:
    //initializes everything to zero/null
    DefaultVector();
    //initializes the max_size to size and allocates this amount of memory
    Loadedvector(int size);
    //initializes the max_size to size and allocates this amount of memory and initializes every element to initial value
    Loadedvector(int size, int &initialValue);
    //delete the vector 
    DeleteVector();
    //returns the max_size
    int capacity() const;
    //returns the no of elements
    int size() const;
    //true if empty otherwise false.empty means elements=0
    bool Isempty() const;
    //resizes it to the size passed as parameter and preserves old elements
    void resize(int size);
    //deletes last element of vector
    bool deleteElement();       
    //add the element at the end if the vector is full call resize.
    bool addElement(int data);  
    // return  array[index]
    int&  returnElement (int index);
    //Vector1=Vector2
    vector& Assign(vector &obj);

};

#endif

i have implemented all the functions in vector.h ,,..
the set.h file is :

#ifndef SET_H
#define SET_H
//NOTE:
//implement the following fuctions by using vector functions
//DO NOT REPEAT THE CODE THAT YOU HAVE ALREADY WRITTEN IN VECTOR FUNCTIONS
//so implement the following fuctions by using vector functions
class Set
{

    private:
        vector *V;
    public:

        //return true if set is empty otherwise false 
        bool IsEmpty( ) ;
        //add the new element.if set is full then resize it and add the element
        void InsertElement(const int & element) ;
        //display the array
        void Print( ) ;
        //read the Set from file and return
        //format element1,element2,element3,........
        //one file will have one array
        Set Read( string filename ) ;
        //Set1=Set2;
        Set &  Assign ( const Set  & S);
        //Set1 union Set2
        Set &  Union (Set& S);
        //Set1==Set2
        //return true if sets are equal otherwise false 
        bool  IsEqual (Set& Set2);
        //Set1-Set2
        SET &  Sub (Set& Set1);
        //Set1 intersection Set2
        SET &   Intersect (Set  &  Set2);
        //return index number of the element
        int Find (const int & element);
        //sort the set in increasing order
        void SortSet(Set  &  Set);
        //return the the elements inbetween Min and Max otherwise empty set.you have to use SortSet function
        Set WithInRange ( const int & Min,const int &  Max);
        //return index number of the element that is before the e.you have to use find function
        //return -1 if not found
        int Before (const int & e);
        //return index number of the element that is after the e.you have to use find function
        //return -1 if not found
        int After ( const int & e);
        //delete the set
        void deleleSet();

        //you can add your helping functions here....

};
#endif

it says that implement the following functions using the vector functions .. now this is a confusing part for me .. please help me with this ..

Edited 3 Years Ago by waqas.zafar.125

I think it means that the functions of Set should call the functions of Vector to do their tasks. For example:

bool Set::IsEmpty()
{
    return V->IsEmpty();
}
This article has been dead for over six months. Start a new discussion instead.