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 constructor in oop?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
#include
Why do we use oop?
Which type does string inherit from?
What is byval and byref? What are differences between them?
What makes a language oop?
What is polymorphism and its types?
What are the two different types of polymorphism?
What is the full form of oops?
Describe these concepts: Polymorphism, Inheritance and Abstraction.
what is the drawback of classical methods in oops?
What is the difference between abstraction and polymorphism?
How can you overcome the diamond problem in inheritance?
What is the benefit of oop?