Groups | Blog | Home
all groups > visual c > june 2007 >

visual c : Compile error in vs2005 but not in vs2003


Ben Voigt [C++ MVP]
6/27/2007 8:24:38 AM

[quoted text, click to view]

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.

[quoted text, click to view]

Ben Voigt [C++ MVP]
6/27/2007 2:17:29 PM

[quoted text, click to view]

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

[quoted text, click to view]

David Wilkinson
6/27/2007 3:14:44 PM
[quoted text, click to view]

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.

--
David Wilkinson
TonyJ
6/27/2007 3:17:34 PM
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

SvenC
6/27/2007 3:24:35 PM
Hi

[quoted text, click to view]

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.

--
SvenC
SvenC
6/28/2007 8:57:08 AM
[quoted text, click to view]

Yes, correct assumption.

--
SvenC
AddThis Social Bookmark Button