Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

CvForestTree and CvBoostTree hides overloaded virtual functions

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>

class base
{
public:
    virtual void fun() { std::cout<<"base fun"<<std::endl; }
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}

    //print and print(int) are overload
    void print() { std::cout<<"print"<<std::endl; }
    void print(int) {std::cout<<"print 2"<<std::endl;}
};

class derived : public base
{
public:
    virtual void fun() { std::cout<<"derived fun"<<std::endl; } //override
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{
    std::unique_ptr<base> base_class(new base);
    std::unique_ptr<base> derive_class(new derived);
    base_class->fun();
    base_class->output(0, 0, 0);
    base_class->print();
    base_class->print(0);

    derive_class->fun();
    derive_class->output(0, 0, 0); //"base output"
    //derive_class->output(0, 0); //compile time error, because the output of derived
                                  //class hide the function of the base class

    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.

CvForestTree and CvBoostTree hides overloaded virtual functionsvirtual functions of the base class CvDTree

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>

class base
{
public:
    virtual void fun() { std::cout<<"base fun"<<std::endl; }
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}

    //print and print(int) are overload
    void print() { std::cout<<"print"<<std::endl; }
    void print(int) {std::cout<<"print 2"<<std::endl;}
};

class derived : public base
{
public:
    virtual void fun() { std::cout<<"derived fun"<<std::endl; } //override
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{
    std::unique_ptr<base> base_class(new base);
    std::unique_ptr<base> derive_class(new derived);
    base_class->fun();
    base_class->output(0, 0, 0);
    base_class->print();
    base_class->print(0);

    derive_class->fun();
    derive_class->output(0, 0, 0); //"base output"
    //derive_class->output(0, 0); //compile time error, because the output of derived
                                  //class hide the function of the base class

    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.

CvForestTree and CvBoostTree hides virtual functions of the base class CvDTree

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>
#include <memory>

class base
{
public:
    virtual void fun() { std::cout<<"base fun"<<std::endl; }
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}

    //print and print(int) are overload
    void print() { std::cout<<"print"<<std::endl; }
    void print(int) {std::cout<<"print 2"<<std::endl;}
};

class derived : public base
{
public:
    virtual void fun() { std::cout<<"derived fun"<<std::endl; } //override
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{
    std::unique_ptr<base> base_class(new base);
    std::unique_ptr<base> derive_class(new derived);
    base_class->fun();
    base_class->output(0, 0, 0);
    base_class->print();
    base_class->print(0);

    derive_class->fun();
    derive_class->output(0, 0, 0); //"base output"
    //derive_class->output(0, 0); //compile time error, because the output of derived
                                  //class hide the function of the base class

    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.

CvForestTree and CvBoostTree hides virtual functions of the base class CvDTree

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>
#include <memory>

class base
{
public:
    virtual void fun() { std::cout<<"base fun"<<std::endl; }
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}

    //print and print(int) are overload
    void print() { std::cout<<"print"<<std::endl; }
    void print(int) {std::cout<<"print 2"<<std::endl;}
};

class derived : public base
{
public:
    virtual void fun() { std::cout<<"derived fun"<<std::endl; } //override
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{
    std::unique_ptr<base> base_class(new base);
    std::unique_ptr<base> derive_class(new derived);
    base_class->fun();
    base_class->output(0, 0, 0);
    base_class->print();
    base_class->print(0);

    derive_class->fun();
    derive_class->output(0, 0, 0); //"base output"
    //derive_class->output(0, 0); //compile time error, because the output of derived
                                  //class hide the function of the base class

    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.

CvForestTree and CvBoostTree hides virtual functions of the base class CvDTree

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>
#include <memory>

class base
{
public:
    virtual void fun() { std::cout<<"base fun"<<std::endl; }
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}

    //print and print(int) are overload
    void print() { std::cout<<"print"<<std::endl; }
    void print(int) {std::cout<<"print 2"<<std::endl;}
};

class derived : public base
{
public:
    virtual void fun() { std::cout<<"derived fun"<<std::endl; } //override
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{
    std::unique_ptr<base> base_class(new base);
    std::unique_ptr<base> derive_class(new derived);
    base_class->fun();
    base_class->output(0, 0, 0);
    base_class->print();
    base_class->print(0);

    derive_class->fun();
    derive_class->output(0, 0, 0); //"base output"
{            
    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.

CvForestTree and CvBoostTree hides virtual functions of the base class CvDTree

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>
#include <memory>

class base
{
public:
    virtual void fun() { std::cout<<"base fun"<<std::endl; }
public:        
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}

    //print and print(int) are overload
    void print() { std::cout<<"print"<<std::endl; }
    void print(int) {std::cout<<"print 2"<<std::endl;}
output"<<std::endl;}           
};

class derived : public base
{
public:
    virtual void fun() { std::cout<<"derived fun"<<std::endl; } //override
public:       
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{            
    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.

CvForestTree and CvBoostTree hides virtual functions of the base class CvDTree

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>
#include <memory>

class base
{
public:        
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}           
};

class derived : public base
{
public:       
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{            
    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.

CvForestTree and CvBoostTree hides virtual functions of the base class CvDTree

When I run the example of tutorial, the clang3.2 give me warning like following.

opencv2/ml/ml.hpp:863:18: note: hidden overloaded virtual function 'CvDTree::train' declared here virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() );

I check the declaration of the header file "ml.hpp"

The derived classes of CvDTree--CvBoostTree and CvForestTree declare an interfaces like this

virtual bool train( CvDTreeTrainData* trainData,
                        const CvMat* subsample_idx, CvBoost* ensemble );

But the signature of the CvDTree are

virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx );

Apparently, this is not override nor overload but hiding, is this the intention of the library?

example :

#include <iostream>

class base
{
public:        
    virtual void output(int, int, int) { std::cout<<"base output"<<std::endl;}           
};

class derived : public base
{
public:       
    virtual void output(int, int) { std::cout<<"derived output"<<std::endl;} //hide the output of base class
};

int main()
{            
    derived derive_class_2;
    derive_class_2.output(0, 0); //output "derived output"
    //derive_class_2.output(0, 0, 0); //compile time error, because the output of derived
                                      //class hide the function of the base class

    return 0;
}

if you want to know more details, please check "exceptional c++ item 21", the book show us how to classify override, overload and hide in depth.