Conversion from a basic type to a class type may be
achieved using______________
Answer Posted / 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 |
Post New Answer View All Answers
What is abstract class in oops?
What causes polymorphism?
What is basic concept of oop?
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
What is a class and object?
What is oops?what is its use in software engineering?
Why is oop useful?
What is abstraction in oops with example?
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 polymorphism and why is it important?
How can you overcome the diamond problem in inheritance?
What are the types of abstraction?
What are the three parts of a simple empty class?
Why is there no multiple inheritance?
What is an advantage of polymorphism?