What is this code doing?

O

oddvark

Hello,

dispose() is a function of dragtool. In the code below, its called
but without the ().

if(parent->dragTool != null)
{
parent->dragTool.dispose;
}

Under MS visual studio 7.1, this compiles. But not under 8. The
question is, what is it really doing under 7.1. Is it making the
function call, or does it think that this is some kind of function
reference?

Thanks.
 
B

Ben Schumeth

Hello,

dispose() is a function of dragtool. In the code below, its called
but without the ().

if(parent->dragTool != null)
{
parent->dragTool.dispose;
}

Under MS visual studio 7.1, this compiles. But not under 8. The
question is, what is it really doing under 7.1. Is it making the
function call, or does it think that this is some kind of function
reference?

The fact that it doesn't compile under VC8 is an indication that it's a
bug in VC7 (although it could of course be the other way around, but
that's less likely). Trying to compile the same code under different
compilers would help strengthen that idea. Without seeing more code it's
impossible to be sure of course, but this does seem like incorrect
syntax. A pointer to the dispose function would be declared as
&DragToolClass::dispose

I'm also somewhat puzzled as to why you compare dragTool to null, when it
is not a pointer, as indicated by the dot operator used inside the if
statement. This could be perfectly alright, but it does look weird.

As to finding out what it does, why don't you just add a line to dispose
to show some output - an assert, a messagebox, printing to stdout, ...
That way you'll see what it does right away.

Ben
 
T

terminator

The fact that it doesn't compile under VC8 is an indication that it's a
bug in VC7 (although it could of course be the other way around, but
that's less likely). Trying to compile the same code under different
compilers would help strengthen that idea. Without seeing more code it's
impossible to be sure of course, but this does seem like incorrect
syntax. A pointer to the dispose function would be declared as
&DragToolClass::dispose

I'm also somewhat puzzled as to why you compare dragTool to null, when it
is not a pointer, as indicated by the dot operator used inside the if
statement. This could be perfectly alright, but it does look weird.

As to finding out what it does, why don't you just add a line to dispose
to show some output - an assert, a messagebox, printing to stdout, ...
That way you'll see what it does right away.

Ben- Hide quoted text -

- Show quoted text -

I guess that code was programmed for microsoft specific extentions to C
++ which cause some syntacticl differences.Search an answer to the
question here:
http://groups.google.com/group/microsoft.public.vc.mfc/topics

regards,
FM
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top