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 a function in oop?
What is overriding in oops?
Why interface is used?
Why is it so that we can have virtual constructors but we cannot have virtual destructors?
What is the main feature of oop?
What is polymorphism what is it for and how is it used?
What is oops and its features?
How is class defined?
What is debug class?what is trace class? What differences are between them? With examples.
What is polymorphism and example?
What are the advantages of polymorphism?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
What does enum stand for?
Templates mean
What is cohesion in oop?