Conversion from a basic type to a class type may be
achieved using______________

Answer Posted / sujatha

Conversion from a basic type to a class type may be
achieved using SUITABLE CONSTRUCTORS IN CLASS.


EX:
class distance
{
int feet;
float inch;


public:

distance(float p) //costructor to concert basic type to
class type
{

feet= (int) p;
inch=(p-feet)*12;
}


void show()
{
cout<<"feet="<<feet;
cout<<"inch="<<inch;
}
};

void main()
{
distance d1=1.75;

d1.show();
}

out put

feet=1;
inch=9;

Is This Answer Correct ?    59 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by variable?

796


What is oops and why we use oops?

822


What is polymorphism and why is it important?

807


What is class and object in oops?

864


What is meant by oops concept?

819


What is encapsulation selenium?

781


What is inheritance and how many types of inheritance?

854


Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

3870


What is coupling in oops?

851


What are main features of oop?

896


What is encapsulation in ict?

836


Is html an oop?

807


Are polymorphisms mutations?

925


What are the two different types of polymorphism?

922


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

981