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...

Can you call a constructor within a constructor?

Answer Posted / jinendra pandey

when i am tring above code getting following error
Can we call a constructor within a constructor?

Error:------------>
object.cpp: In constructor Account::Account():
object.cpp:15: error: this cannot be used as a function


#include<iostream.h>
class Account {
private:
double balance;

// 1st Constructor
public:
Account( double initBalance ) {
balance = initBalance;
}

// 2nd Constructor
public:
Account() {
this( 0.0 ); // call the 1st constructor
}
};

int main()
{
Account a;
return 0;
}

Error:------------>
object.cpp: In constructor Account::Account():
object.cpp:15: error: this cannot be used as a function

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is set ordered?

978


What is the difference between form & report?

1038


What is protected in java?

1002


What is the escape character in java?

994


Is minecraft 1.15 out?

978


Explain about varargs in java?

1131


Why there are some null interface in JAVA? What does it mean? Give some null interface in JAVA?

1087


What’s the difference between unit, integration and functional testing?

1110


What is methodological framework?

1045


Does apple use java?

953


Is null a keyword in java?

977


What is a singleton class? Give a practical example of its usage.

1102


Howto get an object that will perform date & time calculations then format it for output in some different locales with different date style.can ne1 tel me the answer of this question.pls

1921


What is the largest number a double can hold?

1047


Why collection is called framework in java?

990