Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6955421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:44:02+00:00 2026-05-27T14:44:02+00:00

I am trying to set up class hierarchy as follows: template< class TProcess> class

  • 0

I am trying to set up class hierarchy as follows:

template< class TProcess>
class Path
{
protected:
    TProcess &process;
    double Xt;
public:
    Path(TProcess &process, double X0) : process(process), Xt(X0) {}
    virtual ~Path(){}

    virtual double dX(double dt, const std::vector<double> &dW) = 0;
};

template< class TProcess>
class Process
{
protected:
    double X0;
public:
    Process(double X0) : X0(X0) {}
    virtual ~Process(){}

    virtual boost::shared_ptr<Path<TProcess> > NewPath() =0;
};

but then I found it impossible to declare subclasses so that it works. I tried:

class GeometricBrownianMotion;
class GBMPath: public Path<GeometricBrownianMotion>
{
    double dX(double dt, const std::vector<double> &dW)
    {
        Xt = Xt*exp(process.mu*dt - 0.5*dt + process.sigma*dW);
        return Xt;
    }
};

class GeometricBrownianMotion: public Process<GeometricBrownianMotion>
{
    double mu;
    const std::vector<double> &sigma;
    double sigma2;
public:
    GeometricBrownianMotion(double X0, double mu, const std::vector<double> &sigma): Process(X0), mu(mu), sigma(sigma), sigma2(sigma*sigma)
    {}

    virtual boost::shared_ptr<Path<GeometricBrownianMotion> > NewPath()
    {
        return boost::shared_ptr<Path<GeometricBrownianMotion> >(new GBMPath(*this, X0));
    }

};

but I get the following error:

process.h:58: error: forward declaration of ‘struct GeometricBrownianMotion’
process.h:63: error: invalid use of incomplete type ‘struct GeometricBrownianMotion’

Any ideas how to make it work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:44:03+00:00Added an answer on May 27, 2026 at 2:44 pm

    Just separate your implementation from your class definitions, and the problem will go away nearly automatically.

    Nearly, because you might just want to move the definition of GeometricBrownianMotion before using it as a template parameter.

    EDIT: even not nearly, at least on my compiler, removing all inline methods definitions was just enough to get it to compile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set up an inheritance hierarchy similar to the following: abstract class
I am trying to set a custom class to an Iterator through the setInfoClass
I'm trying to set up integration tests using the AbstractTransactionalJUnit4SpringContextTests base class. My goal
I am trying to set a focus on a dropdown within GridView(gridViewDropDown class) when
I'm trying to set a static pointer variable in a class but I'm getting
I'm trying to set up a class so that it's possible to initialize it
I am trying to set slingbox connection to class 1:20 using the following commands:
I'm trying to set a class to active depending on the url. I'm trying
I'm trying to set a class for a li item, with no luck. I
I'm trying to set a Python class property outside of the class via the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.