Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constructor calling a constructor

Status
Not open for further replies.

brownie124

Programmer
Sep 19, 2002
61
US
I receive the error when I compile the code below. What is wrong?
"Only constructors can invoke constructors"
Code:
class MyGroupBox
{
	public void MyGroupBox(int x, int y, int intWidth, int intHeight)
	{
		this(x, y, intWidth, intHeight, "");
	}
		
	public void MyGroupBox(int x, int y, int intWidth, int intHeight, String strCaption)
	{
		// do some stuff here
	}
}

Thanks,
- Michael
 
remove the void from your constructor definitions, you don't need them there.

If that doesnt help i'd try fiddling with this line:

this(x, y, intWidth, intHeight, "");

particually the this bit! i suspect this is what's causing the compiler to panic

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top