Conversion from a basic type to a class type may be
achieved using______________

Answers were Sorted based on User's Feedback



Conversion from a basic type to a class type may be achieved using______________..

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

Conversion from a basic type to a class type may be achieved using______________..

Answer / safe

using object.

Is This Answer Correct ?    18 Yes 9 No

Conversion from a basic type to a class type may be achieved using______________..

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

Conversion from a basic type to a class type may be achieved using______________..

Answer / narmadha

object

Is This Answer Correct ?    8 Yes 3 No

Conversion from a basic type to a class type may be achieved using______________..

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

Post New Answer

More OOPS Interview Questions

What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

0 Answers   IBM,


Difference between realloc() and free?

9 Answers   HP,


What is class and example?

0 Answers  


Is this job good for future? can do this job post grduate student?

0 Answers  


for example A,B,C,D are class all the 4 class contain one method who() but the method who() implementaion is differnet among each class. the relation among the 4 class are A is base class and is inherited by B and C.and from this two B and C where D is inherited. the question is i want to display the output who() method in all the classes(A,B,C,D)the output of who() method is diferrent amond all the class(A,B,C,D) ------A------ virtuval who(print a) override | | who(print b) B C override who(print c) | | -------D------ override who(print d)

2 Answers  






what is polymorpsim? what are its types?

8 Answers  


difference between structure and union.

2 Answers   ADP, Convergys,


Why is oop useful?

0 Answers  


what is function overloading..?

4 Answers  


What is the difference between C++ and java?

6 Answers   Atos Origin,


how to create thread in java?

17 Answers   IBM, Infosys, Wipro,


what is object slicing?

9 Answers   L&T, Wipro,


Categories