Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How can I learn c++ easily?

1027


What is a type library?

1075


Explain the purpose of the keyword volatile.

1110


What is the use of seekg in c++?

1004


What is a syntax in c++?

1121


What is static function? Explain with an example

1012


How to implement is-a and has-a class relationships?

975


What is the difference between a reference and a pointer?

1055


Is java the same as c++?

948


Can we inherit constructor in c++?

1035


Give example of a pure virtual function in c++?

1103


Explain the register storage classes in c++.

1158


Are there any special rules about inlining?

1034


Keyword mean in declaration?

1013


What is c++ redistributable?

1175