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
What is overriding in oops?
• What are the desirable attributes for memory managment?
what is the sylabus for priliminaries?
Where You Can Use Interface in your Project
What is difference between pop and oop?
What is the purpose of polymorphism?
What is the real time example of encapsulation?
What is polymorphism in oops with example?
Prepare me a program for the animation of train
What is encapsulation in oops?
What does and I oop mean in text?
What is property in oops?
What does oop mean in snapchat?
How do you define a class in oop?
What is overriding in oop?