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 are c++ manipulators?
What is overloading unary operator?
Give 10 points of differences between C & C++.
What is helper in c++?
Which operator cannot overload?
What is pointer in c++ with example?
What is c++ course?
Can I have a reference as a data member of a class? If yes, then how do I initialise it?
What is the two main roles of operating system?
Is c++ a high level language?
Where do I find the current c or c++ standard documents?
Explain data encapsulation?
What is c++ array?
Can I learn c++ in a week?
What is the main function c++?