michael » 07 дек 2004, 16:05
Друзья мученики
Как будет выглядеть (copy constructor) для класса LINK
Код: Выделить всё
class ITEM
{ public:
char ch;
private:
ITEM * next;
// ITEM() { l=NULL;}; // constructor private !!!
ITEM (char Val = 0) { ch=Val; next = NULL;}; // constructor private !!!
~ITEM(){;}
public:
char & V() { return ch; } // dirty style: let v to be public
void PrintItem() { cout<<ch<<" ";}
friend class Set_char;
};
class Set_char
{ ITEM * h;
ITEM * current;
ITEM * GetEnd();
// Set_char (Set_char & set) {}; // copy ctr is not accessible
Set_char & operator = (Set_char & set){ return *this;}; // op = is not accessible
public:
Set_char() { h = NULL; }
~Set_char() { Empty(); }
void Empty();
char GetVal( ITEM * t ) { return t->ch;}
bool AddChar(char newChar);
void PrintSet();
ITEM * Append(char ch);
ITEM * GetIt(int N);
ITEM * Start() { current=h; return current; }
ITEM * Next () { current= current->next; return current; }
//***********************OPERATORS
Set_char operator+(char newChar) ;
Set_char operator+(const Set_char & set);
};
Друзья мученики
Как будет выглядеть (copy constructor) для класса LINK
[code]
class ITEM
{ public:
char ch;
private:
ITEM * next;
// ITEM() { l=NULL;}; // constructor private !!!
ITEM (char Val = 0) { ch=Val; next = NULL;}; // constructor private !!!
~ITEM(){;}
public:
char & V() { return ch; } // dirty style: let v to be public
void PrintItem() { cout<<ch<<" ";}
friend class Set_char;
};
class Set_char
{ ITEM * h;
ITEM * current;
ITEM * GetEnd();
// Set_char (Set_char & set) {}; // copy ctr is not accessible
Set_char & operator = (Set_char & set){ return *this;}; // op = is not accessible
public:
Set_char() { h = NULL; }
~Set_char() { Empty(); }
void Empty();
char GetVal( ITEM * t ) { return t->ch;}
bool AddChar(char newChar);
void PrintSet();
ITEM * Append(char ch);
ITEM * GetIt(int N);
ITEM * Start() { current=h; return current; }
ITEM * Next () { current= current->next; return current; }
//***********************OPERATORS
Set_char operator+(char newChar) ;
Set_char operator+(const Set_char & set);
};[/code]