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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.

2575


What is a class and object?

598


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.

1458


Why do we use polymorphism in oops?

579


What is overriding vs overloading?

581






How to call a non virtual function in the derived class by using base class pointer

5256


What exactly is polymorphism?

605


What is encapsulation in simple terms?

537


What is difference between multiple inheritance and multilevel inheritance?

603


Can destructor be overloaded?

597


String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?

1942


What is destructor give example?

603


Why is polymorphism needed?

597


What do you mean by Encapsulation?

640


What is purpose of inheritance?

643