Conversion from a basic type to a class type may be
achieved using______________
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / mohit swami
"constructor"
for example:
class time
{
int hrs;
public:
time(int t) //constructor
{
hrs=t/60;
}
};
void main()
{
time T1; // object T1 is created
int duration=85;
T1=duration; //int to class type
}
| Is This Answer Correct ? | 9 Yes | 3 No |
Answer / kaswan
well i have wrote a full article on how primitive types can
be converted to class type and class to class conversion
also.... if you want to check go ahead!
http://crazylearner.com/type-conversion-in-c/
| Is This Answer Correct ? | 3 Yes | 2 No |
What is class and object in oops?
Program to check whether a word is the first word of the sentence.
How long to learn object oriented programming?
The company is a fake company asking for money of RS10000 while training and not offering a job after training. My humble request to you people not to attend Astersys interview
Write an operator overloading program to Overload ‘>’ operator so as to find greater among two instances of the class.
what is the difference between class and structure in C++?
What is stream in oop?
Pls...could any one tell me that whether we can access the public data memeber of a class from another class with in the same program. Awaiting for your response Thanku
What is a superclass in oop?
What is a class oop?
What are the components of marker interface?
What are the advantages of polymorphism?