Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   help in class and inheritance hierarchical structure (http://www.go4expert.com/forums/help-class-inheritance-hierarchical-t19981/)

s11049151 4Nov2009 18:02

help in class and inheritance hierarchical structure
 
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?

s11049151 4Nov2009 18:05

Re: help in class and inheritance hierarchical structure
 
Oops!

Sorry guys;

it should be:

class d_cam: public camera {

and

class analog_cam: public camera {


Sorry again.

talk2mohdsaif 16Nov2009 15:35

Re: help in class and inheritance hierarchical structure
 
its right whts wrong with u??? ..
u have just define the class......


All times are GMT +5.5. The time now is 13:55.