help in class and inheritance hierarchical structure

s11049151's Avatar
Light Poster
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:
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;
  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;
  virtual void determine_format();
  virtual void print_details();
};

Is this correct?

Last edited by shabbir; 4Nov2009 at 19:34.. Reason: Code blocks
0
s11049151's Avatar
Light Poster
Oops!

Sorry guys;

it should be:

class d_cam: public camera {

and

class analog_cam: public camera {


Sorry again.
0
talk2mohdsaif's Avatar, Join Date: Mar 2009
Go4Expert Member
its right whts wrong with u??? ..
u have just define the class......