Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Vector
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Kai-Uwe Bux, post: 2581389"] Why? Many of the answers to the questions below will depend on your reasons and design goals for the Vector class. Generally: do not roll your own Vector class: std::vector<> is there for a reason. I can only think of two valid reasons to roll your own std::vector<> replacement: a) You want to learn how it's done. b) You need to use vector<T> for an incomplete type T or a type that for some other reasons does not fullfill the requirements of std::vector<> (e.g., T might be copy-constructible but not assignable). Then, you need an implementation that makes stronger niceness guarantees than the standard requires or works around such limitations in some other way. call that push_back(). don't try that. Is this supposed to remove all elements of a given value? Do you really want to remove by value or do you want to remove at a certain position. Are you sure you are designing a vector? Could it be that you are Yes. Well, at least you need to be clear about who the owner is. Yes: use std::vector. If you really need your own, try to mimmick std::vector as closely as possible. In this case: take the arguments by const reference and use the copy constructor to copy them. Best Kai-Uwe Bux [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Vector
Top