Sunday, 8 April 2018

Define a Class Distance with private attributes Feet (int) and Inches (float). Also, define public member functions: - Set_distance() – to assign values to the class attributes - Display_distance() – to display the values of class attributes Include a main() program that creates an instance (object) of type Distance. Ask the user to enter the value of Distance variables and call the appropriate functions to set the object value and then display the object value.

#include<iostream>
#include<conio.h>
using namespace std;
class Distance{
private:
int feet;
float inches;
public:
void set_distance();
void display_distance();
};
int main()
{
Distance t;
t.set_distance();
t.display_distance();
}

No comments:

Post a Comment