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
Why do we use inheritance?
Write a c++ program to display pass and fail for three student using static member function
What is abstraction in oop with example?
Whats oop mean?
How to hide the base class functionality in Inheritance?
What is the example of polymorphism?
What is super in oop?
What is multilevel inheritance explain with example?
What is difference between abstraction and encapsulation?
What is polymorphism give a real life example?
Which language is pure oop?
What is meant by oops concept?
What is interface in oop?
What is the fundamental idea of oop?
What is the real life example of polymorphism?