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 |
In which Scenario you will go for Interface or Abstract Class?
1 Answers InfoAxon Technologies,
i got a backdoor offer in process global,Bangalore..Can i work with it?
When you define a integer it gets stored in which data structure?(Stack or a heap)
Can java compiler skips any statement during compilation time?
WAP to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
When will a constructor executed?
what uses of c++ language?
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.
Name a typical usage of polymorphism
What do you mean by abstraction?
How do you achieve polymorphism?
What is abstraction in oops?