Click here to Skip to main content
15,909,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Unique ID of a computer. Pin
Nishad S31-Aug-07 1:30
Nishad S31-Aug-07 1:30 
AnswerRe: Unique ID of a computer. Pin
Waldermort30-Aug-07 21:34
Waldermort30-Aug-07 21:34 
GeneralRe: Unique ID of a computer. Pin
Nishad S30-Aug-07 21:38
Nishad S30-Aug-07 21:38 
GeneralRe: Unique ID of a computer. Pin
Waldermort30-Aug-07 21:46
Waldermort30-Aug-07 21:46 
GeneralRe: Unique ID of a computer. Pin
Nishad S30-Aug-07 22:18
Nishad S30-Aug-07 22:18 
AnswerRe: Unique ID of a computer. Pin
Russell'30-Aug-07 22:00
Russell'30-Aug-07 22:00 
AnswerRe: Unique ID of a computer. Pin
Sarath C30-Aug-07 22:09
Sarath C30-Aug-07 22:09 
QuestionA linked list is some kind of collection. [modified] Pin
6Qing8830-Aug-07 21:05
6Qing8830-Aug-07 21:05 
Problem:
I run across a problem, briefly, following the concept that a Linked List is a Collection
of some kind, that is to say, a LinkedList class is derived from a Collection class.
Which interfaces should a Collection provide?
Having read some articles about this, conceptually, I though it should provide:
- Insert(basic);
- Add(extensive);
- Append(alias of Add);
- AppendFirst(extensive);
- AppendLast(extensive);
- Remove;
- Clear;
- Contains;
- Capacity;
- Size(optional, actual size in byte);
Back to paper, a linked list should inherit from a collection, that is, all operations
above should be available to the list. But I cannot predict the way a collection stores
its items, dramatically this happens to be the functionality that should be provided by
a linked list, because I consider that a linked list only provides a way to store data.
So there's no way to implement a Collection class without introducting a way to store
data.
One way to follow the concept I metioned above is to make a collection an interface,
that is, the provision of its operations has no implementation, the definition of them
will be given by other classes by which it is inherited. But there's still the problem
unsolved - the operations' prototype are inconsistent, for example:
class ICollection {
public :
/**
* I have to declare the parameter pItem as of type void*.
*/
bool Insert(void *pItem);
};
/**
* Linked List node, the management unit basis of the linked list.
*/
struct ListNode {
};

class LinkedList : public ICollection {
};
/**
* I have to implement the base class's Insert operation which
* takes an undesired parameter that I want it to be replaced
* by ListNode*.
* Otherwise the introduction of ICollection becomes unnecessary.
*/
bool LinkedList::Insert(void *pItem)
{
return (false);
}
The base class's Insert operation is still unnecessary, because
its parameter pItem of type void* is not what I need, I want it to be
of type struct ListNode* instead, but here overloading the operation
makes no sense at least for me.
Had I made the LinkedList a base class of a Collection, I consider it
makes sense because LinkedList provides a mechnism of storing data,
a Collection is in need of this mechnism.
Question:
Is there a way to make a LinkedList a base class of Collection without
breaking the concept that a linked list is some kind of collection.

using namespace System::ComputerCrashArt;


-- modified at 3:15 Friday 31st August, 2007
AnswerRe: A linked list is some kind of collection. Pin
Cedric Moonen30-Aug-07 21:29
Cedric Moonen30-Aug-07 21:29 
AnswerRe: A linked list is some kind of collection. Pin
jhwurmbach30-Aug-07 21:32
jhwurmbach30-Aug-07 21:32 
GeneralRe: A linked list is some kind of collection. Pin
Emilio Garavaglia30-Aug-07 22:04
Emilio Garavaglia30-Aug-07 22:04 
GeneralRe: A linked list is some kind of collection. Pin
jhwurmbach30-Aug-07 22:12
jhwurmbach30-Aug-07 22:12 
GeneralRe: A linked list is some kind of collection. Pin
Emilio Garavaglia30-Aug-07 22:44
Emilio Garavaglia30-Aug-07 22:44 
GeneralRe: A linked list is some kind of collection. Pin
jhwurmbach30-Aug-07 22:48
jhwurmbach30-Aug-07 22:48 
AnswerRe: A linked list is some kind of collection. Pin
Emilio Garavaglia30-Aug-07 22:15
Emilio Garavaglia30-Aug-07 22:15 
QuestionEdit box Pin
Kiran Pinjala30-Aug-07 20:21
Kiran Pinjala30-Aug-07 20:21 
AnswerRe: Edit box Pin
Nishad S30-Aug-07 20:44
Nishad S30-Aug-07 20:44 
AnswerRe: Edit box Pin
chandu00430-Aug-07 20:51
chandu00430-Aug-07 20:51 
GeneralRe: Edit box [modified] Pin
Kiran Pinjala30-Aug-07 21:10
Kiran Pinjala30-Aug-07 21:10 
GeneralRe: Edit box [modified] Pin
chandu00430-Aug-07 21:18
chandu00430-Aug-07 21:18 
AnswerRe: Edit box Pin
6Qing8830-Aug-07 21:31
6Qing8830-Aug-07 21:31 
GeneralRe: Edit box Pin
Nishad S30-Aug-07 21:34
Nishad S30-Aug-07 21:34 
GeneralRe: Edit box Pin
jhwurmbach30-Aug-07 21:34
jhwurmbach30-Aug-07 21:34 
AnswerRe: Edit box Pin
jhwurmbach30-Aug-07 21:36
jhwurmbach30-Aug-07 21:36 
AnswerRe: Edit box Pin
Anurag Gandhi30-Aug-07 23:41
professionalAnurag Gandhi30-Aug-07 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.