Search code examples
c++pass-by-referencederived-classcomputational-finance

C4430 missing type specifier - int assumed


I'm trying to code Put-Call Parity function in CallOption and PutOption derived class. I'd like this function passes the reference of the object as argument.

This is the signature of the function in the CallOption.hpp

double PCParity(const PutOption& put_option) const;

and similarly in PutOption.hpp

double PCParity(const CallOption& call_option) const;

I, of course, included CallOption.hpp in PutOption.hpp and reciprocally.

But I get the following errors:

  • identifier 'PutOption' is undefined.
  • missing type specifier - int assumed. Note C++ doesn't support default-int.
  • syntax error: missing ',' before &

Does it mean that I cannot call two derived classes simultaneously at the compiling time?

Any help is very much appreciated. :(


Solution

  • Thank you @drescherjm for the comments, while you replied I kept searching a solution to my problem. As you said I should use the forward declaration like stated here: What are forward declarations in C++?. Indeed I should include CallOption.hpp in PutOption.cpp and similarly for the CallOption class. Then, declare at the top of CallOption.hpp, as follows:

    Class PutOption;
    Class CallOption: public Option
    {
    }
    

    Many thanks :)