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
Is java as fast as c++?
How do you save a c++ program?
What is the this pointer?
the maximum length of a character constant can be a) 2 b) 1 c) 8
Explain the virtual inheritance in c++.
What flag means?
What are the advantages of c++?
Explain the different access specifiers for the class member in c++.
Which ide is best for c++?
What is an iterator?
What is an overflow error?
What is lvalue?
Write about the various sections of the executable image?
Show the declaration for a static member variable.
Explain class invariant.