本文发表在 rolia.net 枫下论坛I'm not a senior C++ programmer. I understand.
Some time I abuse "const". I know some of them are just make no sense.
Last time you said I didn't understand the source code. you are right, I didn't read all the source code. when I saw :
class ALIST {
public:
void **items;
int numOfItems;
} ;
I ignore the "**", I just assume the item is the pointer to next node, ans ALIST is just a node for MYLIST. It's My mistake.
If you can read what I wrote base on this assumption, you can find out why I made mistakes in #2, #4, #5, #9, #10
For the return of "new". I use C++ from 1998, believe me, all the UNIX/LINUX platform they will not return NULL. At lease I didn't see it. But I don't have lots exp. for Windows. Some people said MS didn't support C++ as good as UNIX. As my experience and the coding policy in my company, we never check NULL after "new" instead , must check exception "try-catch"
If we talk about the iterator, I still suggest to return an iterator for add, remove, delete. If we have iterator, We don't need the function setto (should encapuslated). Please refer to those functions in STL::list
iterator insert(iterator pos, const T& x)
iterator erase(iterator pos)
iterator erase(iterator first, iterator last)
for the #8, you r right, My mistake to put const before, I should use const after: int size() const.
SORRY FOR ALL MY CARELESS.更多精彩文章及讨论,请光临枫下论坛 rolia.net
Some time I abuse "const". I know some of them are just make no sense.
Last time you said I didn't understand the source code. you are right, I didn't read all the source code. when I saw :
class ALIST {
public:
void **items;
int numOfItems;
} ;
I ignore the "**", I just assume the item is the pointer to next node, ans ALIST is just a node for MYLIST. It's My mistake.
If you can read what I wrote base on this assumption, you can find out why I made mistakes in #2, #4, #5, #9, #10
For the return of "new". I use C++ from 1998, believe me, all the UNIX/LINUX platform they will not return NULL. At lease I didn't see it. But I don't have lots exp. for Windows. Some people said MS didn't support C++ as good as UNIX. As my experience and the coding policy in my company, we never check NULL after "new" instead , must check exception "try-catch"
If we talk about the iterator, I still suggest to return an iterator for add, remove, delete. If we have iterator, We don't need the function setto (should encapuslated). Please refer to those functions in STL::list
iterator insert(iterator pos, const T& x)
iterator erase(iterator pos)
iterator erase(iterator first, iterator last)
for the #8, you r right, My mistake to put const before, I should use const after: int size() const.
SORRY FOR ALL MY CARELESS.更多精彩文章及讨论,请光临枫下论坛 rolia.net