August 25th, 2009, 05:08 PM
I have seen this syntax a few times, and im not exactly sure what it means
what exactly is (void)variable doing?
virtual OBJ:OBJThing( ...., unsigned int variable)
August 25th, 2009, 05:09 PM
Most likely it's just trying to suppress an "unused parameter" compiler warning.
August 25th, 2009, 05:17 PM
ha, so its literally doing nothing? Would explain why I could not figure out what it was tring to accomplish.
August 26th, 2009, 01:35 PM
I sure didn't know that, was a learning for me. Thanks.
I have just given a small suggestion (may not be the answer to your question but an alternative).
I guess this is mainly used in virtual functions to maintain the spec. In non-virtual functions this wouldn't normally arise, as you can remove that entire parameter. Also could be used to catch exceptions and if the catch block is not going to use the catch parameter.
I just feel in such scenarios (virtual functions), if you want to retain the spec but not use the parameter at all, then you need not specify the parameter name. Also in catch blocks where you are not going to use the parameter, the parameter name need not be specified.
This shown with an example below (see the function f1 in ClassA and ClassB):
using std :: cout;
using std :: endl;
virtual void f1(int pInt);
class ClassB : public ClassA
ClassA *ptrA1 = &objA;
ClassA *ptrA2 = &objB;
ptrA1 -> f1(5);
ptrA2 -> f1(5);
void ClassA :: f1(int pInt)
cout << "ClassA :: f1(int) invoked\n"
<< "pInt = " << pInt << endl
void ClassB :: f1(int)
cout << "ClassB :: f1(int) invoked\n"
Last edited by Muthuveerappan; August 26th, 2009 at 11:41 PM.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.