C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - Programs (Q.No. 3)
3.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class Bix
{
int x;
public:
Bix();
~Bix();
void Show() const;
};
Bix::Bix()
{
x = 25;
}
void Bix::Show() const
{
cout<< x;
}
int main()
{
Bix objB;
objB.Show();
return 0;
}
Discussion:
19 comments Page 2 of 2.
Jenny said:
6 years ago
First of all, it should be <iostream>
And next would be ~Bix(); as ~Bix(){};
And next would be ~Bix(); as ~Bix(){};
Sindhu said:
1 decade ago
Here x is declared as private so we cannot access x in main function.
Bittoo said:
1 decade ago
If destructor cannot be declared, it must be defined within class.
Swetha said:
1 decade ago
The program get compiled and it provides only run time error.
Guriya said:
1 decade ago
Yes, runtime error: undefined symbol Bix::~Bix().
Prabuferoz said:
1 decade ago
void show() should be declared before destructor.
Jyoti said:
1 decade ago
The destructor is not provided the definition.
Sid said:
1 decade ago
Yes its run time error. So answer is D.
Vineet said:
1 decade ago
Destructor should be define.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers