Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <iostream>
- using namespace std;
- class DSet
- {
- private:
- double* list; //a pointer for the array
- int size; //number of values stored
- public:
- DSet(); //default constructor
- int getSize(); //return the number of elements
- void add(double); //adds a value to list
- ~DSet();
- friend ostream& operator<<(ostream&, DSet);
- bool contains(double);
- };
- //FUNCTION DEFINITIONS
- //Code default constructor
- DSet::DSet()
- {
- //what code goes here?
- //list is initially empty
- }
- int DSet::getSize()
- {
- //return the number of elements in the set
- }
- void DSet::add(double val)
- {
- //add val as the next element of list
- //need to allocate memory 1 bigger than current size
- double* newlist = ; //???
- //copy values from list to newlist
- //add val as last value
- //update size
- //delete old list
- //make new list the list
- }
- //destructor
- DSet::~DSet()
- {
- //release memory
- }
- ostream& operator<<(ostream& out, DSet obj)
- {
- //print each value separated by a space
- }
- bool DSet::contains(double val)
- {
- //return true if val is in the list
- //otherwise return false
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement