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
List some important characteristics on jre
What is map in java?
What are the different access modifiers available in java?
What is identifier in java?
How do you reverse a word in java?
Does java have extension methods?
Can a class with private constructor be extended?
What is the use of volatile in java?
Is a case study a method or methodology?
How to perform quicksort in java?
Can we overload destructor in java?
Why main() method is public, static and void in java ?
What are the advantages of encapsulation in java?
How will you call an Applet using Java Script Function?
Is java programming easy?