© 2012 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies
« NS2  Projects »

Home Lab Exercise Object Oriented Programming Lab Exercise Programs CPP Program To Implement Pure Virtual Function▼


CPP Program To Implement Pure Virtual Function

Alogarithm steps:

Step 1: create a base class namely number and declare the pure virtual function  show().

Step 2: create the derived classes hextype, dectype & acttype from the class number

Step 3: create the objects for the class dectype, hextype and octtype. 

Step 4: call the member function show();

Step 5: Corresponding called function change the integer type as hex ,oct and decimal .

Step 6: Display the values.

CPP Program To Implement Pure Virtual Function

#include class number { protected: int val; public : void setval(int i) {val= i;} //show() is a pure virtual function virtual void show() = 0; }; class hextype : public number { public : void show () { cout<

SAMPLE INPUT AND OUTPUT:

 20
14
24

 

 
SLogix Student Projects

⇓ Student Projects ⇓
⇑ Student Projects ⇑
bottom