define a class length with feet (int type )and (float type) data members.define do-nothing constructor
#include<iostream>
using namespace std;
class length{
private:
int feet;
float inches;
public:
length(){
}
void setLength(int f, float in){
feet = f;
inches = in;
}
void display(){
cout<<feet<<"."<<inches<<endl;
}
};
int main(){
length le;
le.setLength(2, 9998);
le.display();
}
Comments
Leave a comment