2016-12-27 3 views
-2

Ich habe diesen Header für ein Projekt, das ich so mache:Klasse C++ Fehler: „Virtual ist nicht erlaubt“

#include<iostream> 
#include<exception> 
using namespace std; 

class InvalidException : public exception 
{ 
private: 
    string message; 

public: 


    InvalidException(const char *message) 
    { 
     this->message = message; 
    } 


    virtual const char *catch_the_error const throw() 
    { 
     return this->message.c_str(); 
    } 
}; 

Und er sagt, dass virtuelle hier nicht erlaubt ist, und ich weiß nicht, warum, weil mein Ausnahme wird veröffentlicht. Kann mir bitte jemand eine Antwort geben?

+6

Sie haben vergessen, die Funktion Argument '()' Bezeichner, kurz nach 'virtuellen const char * catch_the_error', bevor Sie Ihren' const' und 'Wurf hinzufügen() 'Spezifizierer, – WhiZTiM

Antwort

2

ändern

virtual const char *catch_the_error const throw() 

zu

virtual const char *catch_the_error() const throw() 
Verwandte Themen