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 is abstraction needed?
what is the 3 types of system development life cycle
What are the benefits of interface?
Give two or more real cenario of virtual function and vertual object
How do you answer polymorphism?
Write a program to reverse a string using recursive function?
#include
What is encapsulation process?
What is abstract class in oops?
What is inheritance in oop?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
How does polymorphism work?
when to use 'mutable' keyword and when to use 'const cast' in c++
What is inheritance and how many types of inheritance?
Can enum be null?