abstract class error (invalid new-Expression of Abstract) C++

Asked

Viewed 49 times

-2

Well I’m with an error in my 3 daughter classes(dvd,games,car) of a mother class calls video rental. I am trying to use the Factory method and generates the error in the new with the following message: invalid new-Expression of Abstract class type in the dvd in the game and in the car.

Produto* CriarNovoProduto(){
char letra;
do{
  printf("QUAL PRODUTO?:\n");
  printf("(J)OGO  (C)ARRO  (D)VD\n");
  letra=getchar();
  letra=tolower(letra);
  }while(letra!='j' && letra!='c' && letra!= 'd');
   switch(letra){
            case 'j':
             return new Jogo();
            case 'c':
              return new Carro();
            case 'd':
              return new Dvd();
            default:
               return NULL;
          }
         }

(I don’t know if I can post link with the full code but anyway: https://ideone.com/XLGAoI )

1 answer

-1


the "getpreco" function was not remade in the children

Browser other questions tagged

You are not signed in. Login or sign up in order to post.