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 encapsulation process?
when to use 'mutable' keyword and when to use 'const cast' in c++
Can private class be inherited?
What is the renewal class?
Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.
What is persistence in oop?
Why do we need oop?
Is react oop?
What is the difference between encapsulation and polymorphism?
What is the point of polymorphism?
#include
What does and I oop mean?
What is the point of oop?
What is the real time example of encapsulation?
Why do we use class?