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 the classes in c++?
Explain the difference between overloading and overriding?
What is object file? How can you access object file?
Which is best ide for c++?
What is the latest c++ standard?
Explain the auto storage classes in c++.
Is there a sort function in c++?
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
What is c++ and its uses?
When does a name clash occur in c++?
Why is c++ called oops?
What is enum c++?
Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).
What is #include math h in c++?
Differentiate between a constructor and a destructor in c++.