0

I got an error (It says the Euro_call is inaccessible) when I try to initialize the derived class. Is there any way to fix the error without significant change of the code? I welcome any advice.

class Euro{
protected:
double S;     // spot price

public:
Euro(const double&);
~Euro(){};
};

Euro::Euro(const double& _s):S(_s){}


class Euro_call:public Euro{    
public:
Euro_call(const double&);
~Euro_call(){};
};

Euro_call::Euro_call(const double& _s):Euro(_s){};

class main{
Euro_call a(2.0);   
}
SungwonAhn
  • 57
  • 8

1 Answers1

2

This program is missing an entry point.

The class main{ should be int main() {, and the program may return 0 to indicate successful completion to the operating system.


There is also a redundant ; at the end of:

Euro_call::Euro_call(const double& _s) :Euro(_s) {};

So the full program, with changes to the last 4 lines:

class Euro {
protected:
    double S;     // spot price

public:
    Euro(const double&);
    ~Euro() {};
};

Euro::Euro(const double& _s) :S(_s) {}


class Euro_call :public Euro {
public:
    Euro_call(const double&);
    ~Euro_call() {};
};

Euro_call::Euro_call(const double& _s) :Euro(_s) {}

int main() {
    Euro_call a(2.0);
    return 0;
}
Community
  • 1
  • 1
wally
  • 10,717
  • 5
  • 39
  • 72