Q:

C++ Base class pointer pointing to derived class object doesn't call derived equal operator function

I have a base class Movie and some derived classes (FunnyMovie, DramaMovie, ClassicMovie). I need to store them in Binary Search Trees of Movies. Each movie has different sorting parameters. First I'm trying to sort the FunnyMovies. When I compare two FunnyMovie objects, the FunnyMovie equal operator function is called. But when I compare two Movie pointers containing funny movies, then the Movie equal operator function is called instead of the FunnyMovie equal operator function.
How can I make that the Movie pointers call the equal operator function of the (derived) object they are pointing to instead of the base class Movie function?
Here is the Movie Class:
#ifndef MOVIE_H
#define MOVIE_H
#include <sstream>
#include "RentableItem.h"
#include "Person.h"
using namespace std;

class Movie : public RentableItem
{
    friend ostream& operator<<(ostream &outStream, const Movie& movie);
public:
    Movie();
    Movie(int stock, string directorFirstName, string directorLastName, string title);
    ~Movie();

    string getTitle();
    Person& getDirector();
    char getMediaType();

    virtual bool operator==(const Movie& rhsMovie)const;
    virtual bool operator!=(const Movie& rhsMovie)const;
    virtual bool operator<(const Movie& rhsMovie) const;
    virtual bool operator>(const Movie& rhsMovie) const;
    virtual bool operator<=(const Movie& rhsMovie)const;
    virtual bool operator>=(const Movie& rhsMovie)const;

protected:
    Person* director;   // address
    string title;
    char mediaType;    // it is "D" for all movies as DVD.
};

#endif

Here is the Movie equal operator implementation:
#include "Movie.h"
using namespace std;

bool Movie::operator==(const Movie& rhsMovie)const
{
    return (*this->director == *rhsMovie.director && this->mediaType == rhsMovie.mediaType &&
        this->title == rhsMovie.title);
}

This is FunnyMovie class:
#ifndef FUNNYMOVIE_H
#define FUNNYMOVIE_H
#include "Movie.h"
using namespace std;

class FunnyMovie : public Movie
{
    friend ostream& operator<<(ostream &outStream, const FunnyMovie& movie);
public:
    FunnyMovie();
    FunnyMovie(int stock, string directorFirstName, string directorLastName,
        string title, int releaseYear);
    ~FunnyMovie();

    int getReleaseYear();
    bool operator==(const FunnyMovie& rhsMovie)const;
    bool operator!=(const FunnyMovie& rhsMovie)const;
    bool operator<(const FunnyMovie& rhsMovie)const;
    bool operator>(const FunnyMovie& rhsMovie)const;
    bool operator<=(const FunnyMovie& rhsMovie)const;
    bool operator>=(const FunnyMovie& rhsMovie)const;

private:
    int releaseYear;
};

#endif

Here is FunnyMovie implementation of equal operator:
#include "FunnyMovie.h"
using namespace std;

FunnyMovie::FunnyMovie()
{
    releaseYear = 0;
}

FunnyMovie::FunnyMovie(int stock, string directorFirstName, string  directorLastName,
    string title, int releaseYear) : Movie(stock, directorFirstName, directorLastName, 
    title)
{
    this->releaseYear = releaseYear;
}

FunnyMovie::~FunnyMovie()
{
}

bool FunnyMovie::operator==(const FunnyMovie& rhsMovie)const
{
    return (this->title == rhsMovie.title && this->releaseYear == rhsMovie.releaseYear);
}

I thought that maybe it isn't calling FunnyMovie method because they don't have the same parameters, so I changed
bool FunnyMovie::operator==(const FunnyMovie& rhsMovie)const
// to:
bool FunnyMovie::operator==(const Movie& rhsMovie)const

But then Movie objects don't have releaseYear, and releaseYear is essential for FunnyMovie sorting. 

A:

For a virtual function to work on derived classes, it has to have the same signature as in the base class.  So your operator==() must take a const Movie & argument.
I haven't tried, but what I'd try to do to make your matches more specific is to work with dynamic casts.  Something like what follows.
// The "override" clause makes sure that the virtual function signature matches the one in the base class
bool FunnyMovie::operator==(const Movie &other) const override {
  bool result=false; // Presume different.

  FunnyMovie *fm_other=dynamic_cast<FunnyMovie *>(&other);
  if(fm_other){
    // Perform FunnyMovie comparison with ‘fm_other’ and set ‘result’.
  }
  else{
    // Perform generic Movie comparison with ‘other’ and set ‘result’.
  }

  return result;
}

