I have looked all over and I can't find any resources on this involving the ::
operator.
I have 2 classes: A
and B
. I also have another class C
.
B
inherits from A
, as does C
.
A
contains a method called d
:
A
's .h
file:
class A
{
public:
...
void d();
};
A
's .cpp
file:
...
void A::d()
{
...
}
If I have a B
or a C
, and I run their d
, this method should be run if B
or C
do not have their own overridden d
.
I want to override d
in B
, however it isn't clear to me how I do this. Should I be doing this inside B
's .cpp
file?:
void A::d()
{
...
}
or
void B::d()
{
...
}
and declare it in B
's .h
file?
Or should the function be virtual
?