Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous declaration of functions in the class SoundData #33

Open
Commondor opened this issue Mar 9, 2018 · 5 comments
Open

Erroneous declaration of functions in the class SoundData #33

Commondor opened this issue Mar 9, 2018 · 5 comments

Comments

@Commondor
Copy link

Commondor commented Mar 9, 2018

This is an incorrect function declaration:

    class SoundData
    {
    public:
        virtual bool init(const std::string& filename);
        virtual bool init(const std::vector<uint8_t>& newData);
    };

    class SoundDataWave: public SoundData
    {
    public:
        virtual bool init(const std::vector<uint8_t>& newData) override;
    };

Because some compilers accept std::string for std::vector<uint8_t>. As a result, "virtual bool init (const std::string& filename);" not visible in the classes of the heirs. I suggest changing the name of the function "virtual bool init(const std::vector<uint8_t>& newData);" on "virtual bool initData(const std::vector <uint8_t>& newData);".

For example:

string path = "24-bit.wav";

    // compile error:
SoundDataWave* pSoundDataWave = new SoundDataWave();
pSoundDataWave->init( path );

    // compile ok:
SoundData* pSoundDataWave = new SoundDataWave();
pSoundDataWave->init( path );
@agriic
Copy link

agriic commented Mar 9, 2018

Can you specify compiler?

@Commondor
Copy link
Author

Visual Studio 2017 with last upgrade.

@agriic
Copy link

agriic commented Mar 9, 2018

It is called function hiding.

Should be fixed to:

class SoundDataWave: public SoundData
{
public:
    using SoundData::init;
    bool init(const std::vector<uint8_t>& newData) override;
};

@Commondor
Copy link
Author

It is called function hiding.
Why? Both functions in the base class are public.

@agriic
Copy link

agriic commented Mar 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants