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
Is set ordered?
What is the difference between form & report?
What is protected in java?
What is the escape character in java?
Is minecraft 1.15 out?
Explain about varargs in java?
Why there are some null interface in JAVA? What does it mean? Give some null interface in JAVA?
What’s the difference between unit, integration and functional testing?
What is methodological framework?
Does apple use java?
Is null a keyword in java?
What is a singleton class? Give a practical example of its usage.
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
What is the largest number a double can hold?
Why collection is called framework in java?