Compile error in vs2005 but not in vs2003

  • Thread starter Thread starter TonyJ
  • Start date Start date
T

TonyJ

Hello!

I get compile when using VS2005 but not in VS2003.

The compile error is the following
"Error 1 error C3867: 'MeltPracCommon::ReasonDialog::tbReason_TextChanged':
function call missing argument list; use
'&MeltPracCommon::ReasonDialog::tbReason_TextChanged' to create a pointer to
member c:\pk\development\products\utcas\4.0\src\commoncontrol\ReasonDialog.h
110"

When I click on the error it set the curson on this row."
this->tbReason->TextChanged += new System::EventHandler(this,
tbReason_TextChanged);"

The function tbReason_TextChanged has the following definition.
private: System::Void tbReason_TextChanged(System::Object * sender,
System::EventArgs * e)
{
String* reason = tbReason->Text;
if ( reason->get_Length() == 0 )
this->btnOk->Enabled = false;
else
this->btnOk->Enabled = true;
}

How do I fix the compile error?

//Tony
 
Hi
I get compile when using VS2005 but not in VS2003.

The compile error is the following
"Error 1 error C3867:
'MeltPracCommon::ReasonDialog::tbReason_TextChanged': function call
missing argument list; use
'&MeltPracCommon::ReasonDialog::tbReason_TextChanged' to create a
pointer to member
c:\pk\development\products\utcas\4.0\src\commoncontrol\ReasonDialog.h
110"

When I click on the error it set the curson on this row."
this->tbReason->TextChanged += new System::EventHandler(this,
tbReason_TextChanged);"

I guess the compiler tells you to do this:

this->tbReason->TextChanged += new System::EventHandler(this,
&MeltPracCommon::ReasonDialog::tbReason_TextChanged);

VC2003 was not standard compliant in this area and accepted your old syntax.
 
TonyJ said:
Hello!

I get compile when using VS2005 but not in VS2003.

The compile error is the following
"Error 1 error C3867:
'MeltPracCommon::ReasonDialog::tbReason_TextChanged':
function call missing argument list; use
'&MeltPracCommon::ReasonDialog::tbReason_TextChanged' to create a pointer
to
member
c:\pk\development\products\utcas\4.0\src\commoncontrol\ReasonDialog.h
110"

When I click on the error it set the curson on this row."
this->tbReason->TextChanged += new System::EventHandler(this,
tbReason_TextChanged);"

The function tbReason_TextChanged has the following definition.
private: System::Void tbReason_TextChanged(System::Object * sender,
System::EventArgs * e)
{
String* reason = tbReason->Text;
if ( reason->get_Length() == 0 )
this->btnOk->Enabled = false;
else
this->btnOk->Enabled = true;
}

How do I fix the compile error?

Any reason you didn't just do what it says? You are using a
pointer-to-member here, and the error message gives you the corrected
syntax.
 
SvenC said:
Hi


I guess the compiler tells you to do this:

this->tbReason->TextChanged += new System::EventHandler(this,
&MeltPracCommon::ReasonDialog::tbReason_TextChanged);

VC2003 was not standard compliant in this area and accepted your old
syntax.

He's compiling with /clr:oldSyntax it appears, from the function definition
given. And there was no standard in the VC2003 days.
 
Ben said:
He's compiling with /clr:oldSyntax it appears, from the function definition
given. And there was no standard in the VC2003 days.

Ben:

I think Sven was talking about the general C++ syntax for pointer to
member function, which is not specific to .NET. VC versions prior to VC8
would allow omission of the class name, as well as the required &.

I must say I have never understood why the pointer to member function
syntax gas to be so picky (why the & is not optional, and why the class
name cannot be determined by the usual scoping rules). It seems at odds
with other things in the C++ language.
 
The compile error is the following
Ben:

I think Sven was talking about the general C++ syntax for pointer to
member function, which is not specific to .NET. VC versions prior to VC8
would allow omission of the class name, as well as the required &.

Yes, correct assumption.
 
Back
Top