|
|
what does the data structure want ? list array? some example provide ? |
public
member functions (which could be called form outside (externally) the class) while protected
and private
member functions can only be used inside (internally) the class
|
|
what does this mean? |
new
array of the required size (count
) and copy all items (from object
) to that array and return the array. That's all.Item
. name it set or Set (as in the requirement proposed)ItemName
good for? It's not within your requirement?count
is neither static nor public (it determines how many items object
contains). A better name for object
would be ItemnumOfItem()
should return int, count
actuallyDetermineItem()
(a better name would be FindItem() though).int DetermineItem(T item);
or better int DetermineItem(const T &item);
object
, compare each item (with ==) return -1 if that item cannot be found and the index of the item otherwise.
new
array with size(count
) . it's in a new member function?
|
|
ItemName
u said it's not needed?ItemName
?
|
|
i not really get how to compare with a looping |
|
|
addNewItem();
and RemoveItem();
: both require the parameter item
addNewItem();
adds the item only when FindItem()
returns -1RemoveItem();
removes the item only when FindItem()
returns not -1so how to add the record if without the ItemName? |
|
|
|
|
Item[[100]
will be increase or count
will be increase ? by the way . the name that i pass in for the title is an object //class ?]
it's not a normal variable right?
size_t
. no problem with that. it's basically unsigned int
. I'd prefer int
because you can use negative values.this is for which function already ? and sorry for it. |
when add the item. is the Item[[100] will be increase or count will be increase ? |
count
of course. it's easy, really. Didn't i show it already:
|
|
|
|
the name that i pass in for the title is an object //class ?] it's not a normal variable right? |
string title;
would rather find it's place in that case
.
|
|
int countItem;
countItem++;
case
. It must remain valid for the entire program. while title
could be local for each case
for the case 3 . can i just declare |
i need to overload the == and != operator for the object class so my template based set class can determine membership |
so how should i declare the number of item of the set? because at start i already set the fix sized for N as 100; if i get the N . the result of N will always 100. |
count
is the number of items. N
is only the upper limit
|
|
FindItem()
?isn't for each Item Type ? |
Item == set.Item
compares only the pointers of the array. (a typical pitfall for beginners)so your template based set class can properly determine membership |
|
|
Item == set.Item
is wrong in [almost] any case. You need a loop.Question 2 : Determine if an item is a member of the set. is mean to FindItem() and display it only right? |
|
|
isn't correct? |