help in class and inheritance hierarchical structure

Discussion in 'C++' started by s11049151, Nov 4, 2009.

  1. s11049151

    s11049151 New Member

    Joined:
    Oct 19, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Hi, can someone please tell me if my solution to this question is correct:

    A camera retail shop requires a software to store information about cameras. The shop has two types of cameras: digital and analog. Suppose the shop owner needs to store information only about price, resolution and brand name. He also needs to print the storage format of cameras. System should be able to print the storage format even when other properties of cameras are missing or unupdated. [Hint: create a method for format instead of property] Storage formats cannot be generalized because digital camera stores photos in digital chip while analog camera stores photos in photo reel. Each type of camera MUST specify its storage format by printing storage description on screen like “storage format for analog camera is photo reel”. Create inheritance hierarchical structure for above scenario. Write the class definition with implementation of all the classes you have used above. Keep all the class members public for simplicity.


    Code:
    [COLOR=Blue]class camera {
    public:
      camera();
      ~camera();
      virtual void determine_format();
      virtual void print_details();
    };
    
    class d_cam:public camera {
    public:
      dig_cam();
      ~d_cam();
      float price;
      string resolution;
      string brand_name;
      [/COLOR][COLOR=Blue]virtual void determine_format();
      virtual void print_details();
    };
    
    class analog_cam:public camera {
    public:
      analog_cam();
      ~analog_cam();
      float price;
      string resolution;
      string brand_name;
      [/COLOR][COLOR=Blue]virtual void determine_format();
      virtual void print_details();
    };
    
    Is this correct?
    [/COLOR]
     
    Last edited by a moderator: Nov 4, 2009
  2. s11049151

    s11049151 New Member

    Joined:
    Oct 19, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Oops!

    Sorry guys;

    it should be:

    class d_cam: public camera {

    and

    class analog_cam: public camera {


    Sorry again.
     
  3. talk2mohdsaif

    talk2mohdsaif New Member

    Joined:
    Mar 8, 2009
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Hamirpur(hp)
    its right whts wrong with u??? ..
    u have just define the class......
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice