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
What is meant by object?
This abstract class is correct ? abstract class A { public abstract void Disp(); public abstract void B() { } public absract virtual C() { } }
What is java ceil?
What are the characteristics of Final,Finally and Finalize keywords.
What is data structure in java?
Does unicode support all languages?
What are the data types supported by java? What is autoboxing and unboxing?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What is difference between add() and addelement() in vector?
What is the difference between JVM and JRE?
How do you sort a string in alphabetical order in java?
What is the purpose of void class?
What is bigger kb or mb?
Can we increase array size dynamically in java?
What is the use of arraylist class in java?