InterviewSolution
| 1. |
Write A C++ To Define A Class Box With Length, Breadth And Height As Data Member And Input Value(), Print Value() And Volume() As Member Functions? |
|
Answer»
#include class BOX { private: public: VOID input(); void PRINT(); long volume(long,int,int); }; void BOX::input() { cout<<"input values of l,b,h"<<"n"; cin>>l>>b>>h; } void BOX::print() { out<<"volume="<<"and"; } void BOX::volume() { long volume(long l,int b,int h); { return(l*b*h); } } void main() { set BOX b1; b1.input(); b1.print(); b1.volume(); return; } #include #include class BOX { private: int l,b,h; public: void input(); void print(); long volume(long,int,int); }; void BOX::input() { cout<<"input values of l,b,h"<<"n"; cin>>l>>b>>h; } void BOX::print() { out<<"volume="<<"and"; } void BOX::volume() { long volume(long l,int b,int h); { return(l*b*h); } } void main() { set BOX b1; b1.input(); b1.print(); b1.volume(); return; } |
|