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
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.
What is a class and object?
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.
Why do we use polymorphism in oops?
What is overriding vs overloading?
How to call a non virtual function in the derived class by using base class pointer
What exactly is polymorphism?
What is encapsulation in simple terms?
What is difference between multiple inheritance and multilevel inheritance?
Can destructor be overloaded?
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?
What is destructor give example?
Why is polymorphism needed?
What do you mean by Encapsulation?
What is purpose of inheritance?