I have a question about the use of arrays with polymorphism, the subject is like this: I have a class Article that inherit two classes Book and CD.
class Articulo {
protected:
string nom;
public:
Articulo();
virtual void mostrar() = 0;
}
class Libro : public Articulo{
private:
string autor;
public:
Libro();
void mostrar();
void verAutor();
}
class Cd : public Articulo{
private:
string compositor;
public:
Libro();
void mostrar();
void verCompositor();
}
Then I have a Business class that manages a vector of articles loaded with instances of book and CD.
class Negocio {
private
std::vector<Articulo*> vArticulos;
public:
Negocio();
std::vector<Libro*> buscarPorAutor();
std::vector<Cd*> buscarPorComp();
}
Within Business I have two methods of searching for articles by author (which returns books) and another by composer (returns cds) . As much in book as in cd
I have methods to see the author and the composer, How I can know Of what instance is each element of the vector of articles?