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++
maps and constructors
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="Hicham Mouline, post: 3404899"] Hello, I am attempting to design a class: class C { std::map<double, const A> ma; std::map<double, const B> ma; .. public: C(...); }; The keys in the 2 maps are always identical. So I could choose: std::map<double, const std::pair<A,B> > or std::map<double, const std::pair<A,B>* > (ps: AFAIK, using a const-ref for the pair is impossible, but possible with some boost classes) Q1: Is there a difference in memory usage, access speed or code readability between the top choice and bottom ones? Q2: Between the 2 bottom ones (storing the pair object in the map vs storing the ptr) Q3: For users of class C, what sort of constructors should I offer? C::C(const std::map<double, const std::pair<A,B>* >& ) Or, should I allow adding elements to the map after the object being constructed? C::add(double, const A&, const B&) Rds, [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
maps and constructors
Top