You've hard time to grasp that dynamic array thing, now don't you?
it give me error instead. but that is string what? |
Note that a pointer to the string is returned (
T*
). It points to the first element of the array which has exactly
count
element.
This is how you access it
1 2 3
|
string *getAll = set.getAllItems() // Note the *
...
delete[] getAll; // Note the position of []
|
why i cannot return with a string value? |
Because it's an array with possibly more than one [string].
and why the address will still show out? |
It's an array! you have to use a loop to show the elements of that array
and why i cant test my set with class object d? |
Within
firstclass
,
secondclass
, or whatever class you have to implement the operators:
1 2
|
bool operator==(...)
bool operator!=(...)
|
(Since you're using only the == operation whithin
Set<T>
you just have to override the operator==)
This is meant when stating:
then you may need to overload the == and != operators for the object’s class so your template based set class can properly determine membership. |