Override function with enum / int

If there was a base class DeriveMe that had a function virtual void DoSomething(int)and a class that inherits DeriveMe, called DerivedThat that had a function void DoSomething(SomeEnum)..., DerivedThat overrides the base class DoSomething, because enums compute ints at compile time in C ++?

I could try this by making DoSomething pure virtual and compiling / running it to see if it works, but this is my first question with stackoverflow, so I would just ask for it.

+3
source share
1 answer

No, it DerivedThatwill hide the function from the base class, since the signatures do not match. enumare not evaluated until int, as they are a separate type.

See C ++ Frequently Asked Questions, sections 23.9 and 29.19 .

+8
source

Source: https://habr.com/ru/post/1703456/


All Articles