Public Group

# C++ declaration/definition question

This topic is 3758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Best way I could summarize for the title on the spot here. Consider this: A class Beta inherits from class Alpha and needs to override a function in Alpha. Here is Beta's class declaration:
class Beta : public Alpha
{
Beta::Beta();
~Beta::Beta();

void paint(CustomClass *ptrToCCObj); // this is being overridden, it's from Alpha
}

and in the definition...
void Beta::paint(CustomClass *)
{
// some drawing code here that doesn't reference ptrToCCObj at all
}

My question is: What is being done with *ptrToCCObj? My guess is that since it's being overridden that the target class has this argument (and needs to have it when it's being overridden so it's not instead overloaded) but the inheriting class doesn't have any use for it. Is that in fact what's going on? Is there a name for this practice? Is this a hack? Thank you for your time. EDIT: Forgot to put a return type on said-class.

##### Share on other sites
Quote:
 Original post by serratemplarMy guess is that since it's being overridden that the target class has this argument (and needs to have it when it's being overridden so it's not instead overloaded) but the inheriting class doesn't have any use for it. Is that in fact what's going on? Is there a name for this practice? Is this a hack?

Yes, not that I'm aware of, and no. Taking a parameter without naming it is a convenient and correct way of keeping the compiler from issuing a warning about an unreferenced parameter.

##### Share on other sites
=)

Thank you very much.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
20
4. 4
5. 5

• 27
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631735
• Total Posts
3001939
×