동적 배열 int
값의 힙에 해당 요소를 저장하는 Set
개체를 어떻게 만들 수 있습니까? 특히, 이러한 사양을 가진 빈 집합을 만드는 방법은 무엇입니까? 당신이 경우동적 배열의 힙에 요소가있는 클래스 집합
:
// Morally Right (M) 2014 1-ling. All morals preserved.
class Set
{
public:
Set();
Set(int element);
Set(const Set& s);
~Set();
bool contains(unsigned int element);
unsigned int getSize();
int operator[](unsigned int index) const;
Set& operator=(const Set s);
Set operator+=(const Set s) const;
Set operator-=(const Set s) const;
Set operator*=(const Set s) const;
friend ostream& operator<<(ostream& o , const Set& s);
friend istream& operator>>(istream& i , const Set& s);
private:
int *array = new int[size]; // IS THIS THE PATH TO SUCCESS?
int* elements();
unsigned int size();
void copy(const Set& s);
void resize(unsigned int new_size);
};
은'사용자 정의 클래스 또는 컨테이너의 어떤 종류의 이름을 Set' 있습니까? – 0x499602D2
내 편집보기 ...... –
UCLA에 가면이 코드를 복사하지 마십시오. 너 스스로해라. 나는 교수님이 당신이 똑같은 구조로 작업을 시작하면 이것을 벗겨 내고 싶지 않습니다. –