Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A weired thing in VC++/CLR compiler

1 view
Skip to first unread message

Saeed Amrollahi

unread,
Mar 2, 2011, 3:18:17 AM3/2/11
to
Dear All
Hi

During writing a typical Windows Form Application using CLR,
I found something strange in Visual C++ compilrer. consider the
following class:

// LoginForm.h
public ref class LoginForm : public System::Windows::Forms::Form {
LoginForm^ FillOperModeBox();
LoginForm^ FillUsernameBox();
// other stuff
};

As you see, there are two private member functions to fill
Operation Mode and Username comboboxes.
I used a varient of Method Chaning technique in C++,
because the restrictions of CLR I can't use LoginForm& as
return type, so I have to use LoginForm^. In other words,
I use 'this pointer' rather than object itself (*this).
So I can write in Form constructor:
LoginForm::LoginForm()
{
FillUsernameBox()->FillOperModeBox(); // method chaning
}

in LoginForm.cpp, I wrote:
LoginForm::FillUsernameBox()
{
// fill the combobox

}

I forgot to return this pointer.
At the moment if you compile the file (F7), there is no error,
but if you build the project, there is an error message:
LoginForm::FillOperModeBox' : must return a value
It's obvious, such thing can be caught by comipler
at separate comiplation.
Is it a bug in VC++ compiler?

Thanks in advance
-- Saeed Amrollahi

0 new messages