Witam,
Problem polega na tym, ze robie chcial bym miec klase, ktora zawiera inna klase ktora dziedziczy po std::logic_error, ktora to posiada metode what(), niestety nie wiem czemu w moim przypadku nie dziala ona... b.what();
#include <iostream>
#include <stdexcept>
#include <string>
#include <cmath>
class Bad_hmean {
public:
class Bad : public std::logic_error{
public:
Bad(const std::string & what_arg = "FATAL ERROR"):std::logic_error (what_arg){}
};
};
double hmean(double a, double b);
int main(){
using std::cout;
using std::cin;
using std::endl;
double x,y,z;
x = 2;
y = -2;
try{
z=hmean(x,y);
cout<<"result "<<x<<" "<<y<<" = "<< z<<endl;
}
catch(Bad_hmean::Bad & b){
b.what();
}
}
double hmean(double a, double b){
if(a==-b)
throw Bad_hmean::Bad("FATAL");
return 2.0*a*b/(a+b);
}