tags:

views:

182

answers:

5
void useproxynum    ( ) { bUseProxy = true; return; };
void useacctnum     ( ) { bUseProxy = false; return; };

Can anyone give me some insight into what these c++ statements are doing? There are in a header file. bUseProxy is defined above

bool    bUseProxy;

I'm trying to figure out what useproxynum is (method call?) and I'm also trying to figure out how to find the code behind it.

This is in Visual Studio 6.

+10  A: 

They are inline method definitions. The return statements are extremely unnecessary.

If it were me, i'd replace that with this:

void useNum(bool proxy) { bUseProxy = proxy; }
Jacob Relkin
+1 on the bold usage.
Tom
How is it **extremely** unnecessary vs. just ordinarily unnecessary? ;) (It's completely a no-op statement, so it's not like it really is extreme...)
Reed Copsey
@Reed: It's like infinite and 2x infinite, both are infinite, but one grows faster than the other :)
Brian R. Bondy
@Brian: It's more like it's **extremely** infinite. That's way more than infinite, of course. ;)
Reed Copsey
I guess on second thought it's more like saying 5 * 0 vs 0*0. Clearly 0*0 is a more **extreme** 0 than 5*0!
Brian R. Bondy
Some statements are more unnecessary than others.
glowcoder
This is a very unique discussion.
stusmith
*Extremely* unique!
FredOverflow
Are they more or less unnecessary than the semicolons after the function bodies?
Mike Seymour
@Mike: Well played
Brian R. Bondy
+1  A: 

They are both methods. The lines between the { } are the code. These are inlined methods and don't have a separate implementation in a .cpp file.

Amardeep
+1  A: 

they are inline methods. when called, they set the value of the boolean, then return.

Randy
+2  A: 

You can call useproxynum() in your code, and it will cause the bUseProxy value to be set to true.

Or, you can call useacctnum() in your code and it will cause bUseProxy to be false.

This bUseProxy is probably used somewhere else.

void doSomething(int id) {
    if(bUseProxy) {
        lookupWithProxy(id);
    }
    else {
        lookupWithAccNum(id);
    }
}

It's worth noting that the return; statements are kind of silly - reaching the end of the function block will cause the function to return all by itself.

"Trying to figure out the code behind it" ... no no, the code is in front of it =)

glowcoder
Does it show that c++ is not my strong suit. Don't tell my boss LOL.
codingguy3000
+3  A: 

Those are not statements. Those are 2 methods (seems to be inline). One of them just sets true to bUseProxy variable the other sets false. Thats it.

Incognito