shogun-toolbox / shogun

Shōgun
http://shogun-toolbox.org
BSD 3-Clause "New" or "Revised" License
3.03k stars 1.04k forks source link

fix overloading problems in FeatureSelection.h #2462

Open vigsterkr opened 10 years ago

vigsterkr commented 10 years ago
In file included from /usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/BAHSIC.cpp:32:
In file included from /usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/BAHSIC.h:35:
In file included from /usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/KernelDependenceMaximization.h:35:
In file included from /usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/DependenceMaximization.h:35:
/usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/FeatureSelection.h:311:7: warning: 'shogun::CFeatureSelection<double>::init' hides overloaded virtual function [-Woverloaded-virtual]
        void init();
             ^
/usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/DependenceMaximization.h:67:40: note: in instantiation of template class 'shogun::CFeatureSelection<double>' requested here
class CDependenceMaximization : public CFeatureSelection<float64_t>
                                       ^
/usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/Preprocessor.h:89:15: note: hidden overloaded virtual function 'shogun::CPreprocessor::init' declared here: different number of parameters (1 vs 0)
        virtual bool init(CFeatures* features)=0;
                     ^
In file included from /usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/BAHSIC.cpp:32:
In file included from /usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/BAHSIC.h:35:
/usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/KernelDependenceMaximization.h:100:7: warning: 'shogun::CKernelDependenceMaximization::init' hides overloaded virtual function [-Woverloaded-virtual]
        void init();
             ^
/usr/home/wiking/shogun-buildbot/bsd1_-_libshogun/build/src/shogun/preprocessor/DependenceMaximization.h:120:15: note: hidden overloaded virtual function 'shogun::CDependenceMaximization::init' declared here: different number of parameters (1 vs 0)
        virtual bool init(CFeatures* features);
                     ^
2 warnings generated.
lambday commented 10 years ago

@vigsterkr what is wrong with having two inits with different parameters? The following code doesn't show any error/warning on gcc

#include <iostream>

using namespace std;

class Preprocessor
{
public:
    Preprocessor()
    {
        cout << "Preprocessor constructor called" << endl;
    }
    virtual bool init(int a) = 0;
    virtual ~Preprocessor()
    {
        cout << "Preprocessor destructor called" << endl;
    }
};

template <class T> class FeatureSelection : public Preprocessor
{
public:
    FeatureSelection<T>()
    {
        init();
        init(10);
        cout << "FeatureSelection constructor called" << endl;
    }
    virtual bool init(int a)
    {
        cout << "overridden init()" << endl;
    }
    virtual ~FeatureSelection<T>()
    {
        cout << "FeatureSelection destructor called" << endl;
    }
private:
    void init()
    {
        cout << "private init()" << endl;
    }
};

int main()
{
   cout << "Hello World" << endl; 
   FeatureSelection<double> *fs = new FeatureSelection<double>();
   delete fs;
   return 0;
}