I've used VisualAssistX Implement Virtual Methods
option and it generated:
class Base: public IBase
{
public:
Base(void);
~Base(void);
virtual void IBase::Foo();
I've noticed that I can omit IBase
and program still compiles like that:
virtual void Foo();
If this is the same code? Why VisualAssistX inserts IBase::
? Is it just kind of "code-style" to improve readability?
Thanks
This would help resolve the ambiguity if you were to derive from multiple base classes with clashing virtual functions. I suspect this is the reason why VisualAssistX is choosing to insert the IBase::
.
Whether IBase::
helps improve readability is debatable. I personally find it distracting.
Furthermore, the syntax is not even standard C++. See Distinct implementations for pure virtual functions with same name for a discussion and for a suggestion how the multiple inheritance problem can be solved using standard, portable C++.
Definitely not improving readability, the other way around. The scope prefix is for use from outside or when there can be resolution ambiguity, using the prefix inside the scope itself just obfuscates the code and actually contradicts OOP principles. When inside scope your entity doesn't need to indicate it again, it's completely redundant. Regarding the VA I can only speculate that it was simpler for implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With