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
How can I learn c++ easily?
What is a type library?
Explain the purpose of the keyword volatile.
What is the use of seekg in c++?
What is a syntax in c++?
What is static function? Explain with an example
How to implement is-a and has-a class relationships?
What is the difference between a reference and a pointer?
Is java the same as c++?
Can we inherit constructor in c++?
Give example of a pure virtual function in c++?
Explain the register storage classes in c++.
Are there any special rules about inlining?
Keyword mean in declaration?
What is c++ redistributable?