Undefined character using pattern

I get a linker error by creating this code:

File Exclude.h

class IsExclude
{
    public:
        template<typename T>
        bool operator()(const T* par);
        virtual ~IsExclude() = 0;
};

IsExclude::~IsExclude() {}

class IsExcludeA : public IsExclude
{
    public:
        IsExcludeA(std::string toCompare) : toCompare_(toCompare)  {}
        template<typename T>
        bool operator()(const T* par)
        {
            return strcmp(par->Something, toCompare_.c_str() ) ? false : true ; 
        }
        ~IsExcludeA() {}
    private:
        std::string toCompare_;
};

In the same file:

/*
 * loop over a container of function objects
 * if at least one of them return true the function
 * return true, otherwise false
 * The function was designed to evaluate a set of
 * exclusion rule put in "and" condition.
 */
template<typename T,typename P>
bool isExclude( const T& cont, const P* toCheck )
{
    typename T::const_iterator pos;
    typename T::const_iterator end(cont.end());
    bool ret(false);
    for (pos = cont.begin(); pos != end; ++pos)
    {
        if ( (*pos)->operator()(toCheck) == true )
        {
            ret = true;
            pos = end;
        }
    }    
    return ret;
}

The cpp file in which I am using the previous call looks like this:

std::vector<IsExclude* > exVector;

exVector.push_back( new IsExcludeA(std::string("A")) );
exVector.push_back( new IsExcludeA(std::string("B")) );

if (isExclude(exVector,asset) == false)
{
     // Blah
}

The code compiles fine, but I got an error from the linker: Undefined first link character in bool IsExclude :: operator () (const __type_0 *) MyFile.o

Do you have any hints or suggestions?

PS I know that I need to clear the vector to avoid a memory leak. I can not use boost :: shared_ptr with my compiler. Sigh!

+3
source share
1 answer

In a function, isExcludeyou write:

if ( (*pos)->operator()(toCheck) == true )

IsExclude::operator(), , , . , operator(), " ".

, , , , , operator() operator().

+3

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


All Articles