C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - Programs (Q.No. 12)
12.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class IndiaBix
{
    int x; 
    public:
    IndiaBix(short ss)
    {
        cout<< "Short" << endl;
    }
    IndiaBix(int xx)
    {
        cout<< "Int" << endl;
    }
    IndiaBix(float ff)
    {
        cout<< "Float" << endl;
    }
    ~IndiaBix() 
    {
        cout<< "Final";
    }
};
int main()
{
    IndiaBix *ptr = new IndiaBix('B');
    return 0; 
}
The program will print the output Short .
The program will print the output Int .
The program will print the output Float .
The program will print the output Final .
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
14 comments Page 2 of 2.

Saman said:   7 years ago
There should be a statement for namespace (using namespace std), otherwise it cause an error.

VIVEK ROY said:   5 years ago
Please see the steps:

1. At first. the compiler will try for an exact match.
2. If failed, then it will do integral promotion, (char->int, float->double) and try to match, what it's doing here.
3. If failed. then it will do for built-in conversion and try to match.
4. If failed, then it will try user-defined conversion and match again.
(3)

Raj said:   5 years ago
Why final not printed? Please explain about it.

Altu said:   5 years ago
Final is not printed because Object is not deleted.
No delete has been called and the pointer is not a smart pointer.
(1)


Post your comments here:

Your comments will be displayed after verification.