Find out the bug in this code,because of that this code
will not compile.......
#include <iostream>
#include <new>
#include <cstring>
using namespace std;
class balance {
double cur_bal;
char name[80];
public:
balance(double n, char *s) {
cur_bal = n;
strcpy(name, s);
}
~balance() {
cout << "Destructing ";
cout << name << "\n";
}
void set(double n, char *s) {
cur_bal = n;
strcpy(name, s);
}
void get_bal(double &n, char *s) {
n = cur_bal;
strcpy(s, name);
}
};
int main()
{
balance *p;
char s[80];
double n;
int i;
try {
p = new balance [3]; // allocate entire array
} catch (bad_alloc xa) {
cout << "Allocation Failure\n";
return 1;
}
Answer Posted / santhoo035
Default constructor is not overriden
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What is a class template?
Will a C compiler always compile C++ code a) Yes b) No c) Only optimized compilers
What is the use of map in c++?
What is meant by const_cast?
What is the importance of mutable keyword?
Explain about vectors in c ++?
Is c better than c++?
What is different in C++, compare with unix?
What is difference between class and function?
What is the difference between the functions rand(), random(), srand() and randomize()?
Carry out conversion of one object of user-defined type to another?
How much is c++ certification?
What is the difference between object-oriented programming and procedural programming?
What does the linker do?
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list