Enter the value for feet and inch and then display the values at screen | Taking the Values for Feet and Inch and Display them | OOP Programming
Taking the Values for Feet and Inch and Display them | OOP Programming |
We use Private for hidden objects for our secret purposes and we can not directly access Private objects so we use Public objects to access and assign and show values stores in Private using Public
this all syntax is basically all is like Structures and we shall use functions to display values
Enter the value for feet and inch and then display the values at screen |
#include<iostream>
using namespace std;
class dist
{
private:
int feet;
int inch;
public:
void distance()
{
cout<<"Enter the value of feet:";
cin>>feet;
cout<<"Enter the value of inches:";
cin>>inch;
}
void display()
{
cout<<"Feets are:"<<feet<<endl;
cout<<"Inches are:"<<inch<<endl;
}
};
int main ()
{
dist d;
d.distance();
d.display();
system("pause");
}
COMMENTS