Re: Error; Why is VS C++ deleting my events from the form?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Larry Brasfield (donotspam_larry_brasfield_at_hotmail.com)
Date: 02/08/05


Date: Tue, 8 Feb 2005 10:34:40 -0800


"_Christopher(M2M)" <cdhuk2000@yahoo.co.uk> wrote in
 message news:cuapqr$bec$1@titan.btinternet.com...
> "Larry Brasfield" <donotspam_larry_brasfield@hotmail.com> wrote in message news:eMrIWBeDFHA.1524@TK2MSFTNGP09.phx.gbl...
>> "_Christopher(M2M)" <cdhuk2000@yahoo.co.uk> wrote in
>> message news:cua81e$if3$1@titan.btinternet.com...
>> [big snip]
>>> I think I have found a work around:-
>>> It work OK if I included the 'System::Windows::Forms::'
>>>
>>> WAS:
>>> this->button1->MouseDown += new MouseEventHandler(this, Button_MouseDown);
>>>
>>> NOW:
>>>
>>> this->button1->MouseDown += new System::Windows::Forms::MouseEventHandler(this, Button_MouseDown);
>>>
>>> So is there a problem with the 'using namespace'?
>> Such problems generally show up at compile time.
>> (The exception is when you don't know what you are
>> doing and use the wrong name.)
>>
>> If changing that scope qualification changed the behavior
>> of your code, than that fact establishes that a different
>> object was bound to the resulting name. I would expect
>> that, in the absence of some other change you have not
>> mentioned, the result of the above change would be to
>> go from "will not compile" to "does compile". So, if
>> there was also a "using namespace ..." change, and if
>> that construct allowed you to use a name from a
>> different namespace than you intended, then I would
>> agree that there was indeed a specific problem with the
>> "using namespace ..." construct. In general, namespace
>> merging is a hazard, so I avoid use of the 'using' construct
>> to get at multiple namespaces in the same scope. In my
>> opinion, it is asking for trouble.

> Can I ask you, did you try to compile the programme? If so did
> it compile and run OK.

I saw no reason to create a project, paste code, etc.
My comments result from a study of your posts and
knowledge of C++.

> It compiles OK here with the namespaces as thay are.

I think you miss my point. Consider the following code:
  namespace something {
    using namespace ::whatever;
    somename var1;
    ::whatever::somename var2;
  }
If, for the var1 definition, 'somename' can be pulled out of the
combination of { whatever was naturally in namespace something }
and { the ::whatever namespace }, and if '::whatever::somename' binds
to something different than plain 'somename', then it must be the case
that plain 'whatever' is ambiguous in that scope. That should fail to
compile if the compiler is working right. There would be no ambiguity
only if '::whatever::somename' and 'somename' refer to the same object.

Since you claim a behavioral change by using a different name, it must
be because either { you are mistaken about the behavior change being
due to that code change } or { the change of name caused a change of
referent }. If the latter, then I cannot see how you avoided an ambiguous
name error if you had the 'using System::Windows::Forms;' statement
present all along as you claimed in your post yesterday.

> Thanks.

I guess you're welcome, but I do not imagine this is useful, yet.
There is something strange going on here which, once it is
unearthed, may prove useful to know.

-- 
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me. 

Quantcast