Thread: Vector of Objects and Constructors

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Registered User
    Join Date
    Nov 2010
    Posts
    122
    Thank you very much for you answer.

    Quote Originally Posted by Elysia View Post
    For diamond store, are you sure you want to separate all different products? In the future, if you decide to add more products, you have to add more state, which increases memory and add new functions. Or you could just use the fact that they all are products and have only one adder, getter, possibly finder and deleter.
    Also since you store books (which can be comic books), you really need polymorphism here, so std::vector<Book> should be std::vector<std::unique_ptr<Book>>.
    I must split in two my doubts.
    I think that makes all sense use only one "add function" to create the different type of products (different subClasses). I think that I was avoiding put it on design, because I don't know how to implement this kind of function.
    I think that you're right about the Polymorphism in Book and ComicBook. I need to read more about the subject because I didn't get how it can be implemented.

    Creating a conceptual problem was very useful. I figured out how important is the design fase, how important is study some subjects such as Composition or Polymorphism.

    This is my current ClassDiagram:
    https://dl.dropboxusercontent.com/u/...0diagram_5.png
    Last edited by marcoesteves; 07-25-2014 at 10:36 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array of Objects with Constructors
    By Eman in forum C++ Programming
    Replies: 1
    Last Post: 10-26-2010, 03:49 PM
  2. Initializing Objects with constructors
    By freddyvorhees in forum C++ Programming
    Replies: 1
    Last Post: 07-24-2008, 07:11 AM
  3. Passing Objects to Constructors and Receiving a Logic Error
    By CaptainMorgan in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2006, 06:39 AM
  4. objects + [copy]constructors + etc
    By krygen in forum C++ Programming
    Replies: 2
    Last Post: 01-16-2005, 06:19 AM
  5. Constructors for Composed Objects
    By gozlan in forum C++ Programming
    Replies: 13
    Last Post: 10-18-2002, 03:37 PM

Tags for this Thread