A weired thing in VC++/CLR compiler

  • Thread starter Saeed Amrollahi
  • Start date

S

Saeed Amrollahi

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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top