Loser throw specifier in c++ [closed]

  access-specifier, c++, exception, specifier

Hello i have this code in c++,
I am creating my own exception class but it throws and error saying Loser throw specifier

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

///Q NO:1
class IceCreamConeException:public runtime_error
{
public:
    string flavr;
    int scop;
    IceCreamConeException(string str, string f, int s):runtime_error(str),flavr(f),scop(s){}

};
class IceCreamCone
{
private:
    string flavor;
    int scoops;
public:
    IceCreamCone()
    {
        setflavor();
        setscoops();
    }
    void setflavor()
    {
        cout<<"Enter flavor:"<<endl;
        cin>>flavor;
    }
    void setscoops()
    {
        cout<<"Enter scoops:"<<endl;
        cin>>scoops;
        
        if(scoops>3)
            throw IceCreamConeException("scoops are greater than 3:",flavor,scoops);
        cout<<"Total scoops are:"<<scoops<<endl;


    }
};
int main()
{
    try
    {
        IceCreamCone obj;
    }
    catch(IceCreamConeException &obj1)
    {
       cout<<"flavor is:"<<obj1.flavr<<"n"<<"Total scoops are:"<<obj1.scop<<"n"<<obj1.what()<<endl;
    }
    return 0;
}

This is my code.
If i change the data type of flavr in IceCreamConeException to int, then it will work fine but somehow it does not work with string data type,
Can anyone help me

Source: Windows Questions C++

LEAVE A COMMENT