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

  • Home
  • SEARCH
  • 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 8558577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:50:39+00:00 2026-06-11T15:50:39+00:00

I have the following code: namespace { class CatBondEvent { public: CatBondEvent(Date date) :

  • 0

I have the following code:

namespace {
    class CatBondEvent
    {
    public:
        CatBondEvent(Date date) : date(date){}
        virtual ~CatBondEvent(){}
        Date date;

        bool operator< (CatBondEvent &other) { return date<other.date;}
    };

    class CatEvent : CatBondEvent
    {
    public:
        Real loss;
        CatEvent(Date date, Real loss) : CatBondEvent(date), loss(loss) {}
    };

    class CollateralCoupon : CatBondEvent
    {
    public:
        Real unitAmount;
        CollateralCoupon(Date date, Real unitAmount) : CatBondEvent(date), unitAmount(unitAmount) {}
    };

    class CatBondCoupon : CatBondEvent
    {
    public:
        CatBondCoupon(Date date) : CatBondEvent(date) {}
    };

    void fillEvents(std::vector<boost::shared_ptr<CatBondEvent> > &events, 
                    Date startDate,
                    Date endDate,
                    boost::shared_ptr<std::vector<std::pair<Date, Real> > > catastrophes, 
                    boost::shared_ptr<Bond> collateral,
                    boost::shared_ptr<std::vector<Date> > couponDates)
    {
        for(int i=0; i<catastrophes->size(); ++i) 
        {
            events.push_back(boost::shared_ptr<CatBondEvent>(new CatEvent((*catastrophes)[i].first, (*catastrophes)[i].second)));
        }
        const Leg& cashflows = collateral->cashflows();
        for(int i=0; i<cashflows.size() && cashflows[i]->date()<=endDate; ++i) 
        {
            boost::shared_ptr<CashFlow> cashflow = cashflows[i];
            if(cashflow->date() >= startDate)
            {
                events.push_back(boost::shared_ptr<CatBondEvent>(new CollateralCoupon(cashflow->date(), cashflow->amount())));
            }
        }
        for(int i=0; i<couponDates->size(); ++i) 
        {
            Date couponDate = (*couponDates)[i];
            if(couponDate >= startDate)
            {
                events.push_back(boost::shared_ptr<CatBondEvent>(new CatBondCoupon(couponDate)));
            }
        }
    }
}

And I get the following compilation errors:

Error   37  error C2243: 'type cast' : conversion from '`anonymous-namespace'::CollateralCoupon *' to '`anonymous-namespace'::CatBondEvent *' exists, but is inaccessible   c:\boost\boost_1_49_0\boost\smart_ptr\shared_ptr.hpp    184
Error   36  error C2243: 'type cast' : conversion from '`anonymous-namespace'::CatEvent *' to '`anonymous-namespace'::CatBondEvent *' exists, but is inaccessible   c:\boost\boost_1_49_0\boost\smart_ptr\shared_ptr.hpp    184
Error   38  error C2243: 'type cast' : conversion from '`anonymous-namespace'::CatBondCoupon *' to '`anonymous-namespace'::CatBondEvent *' exists, but is inaccessible  c:\boost\boost_1_49_0\boost\smart_ptr\shared_ptr.hpp    184

Any idea what went wrong and how to fix it?

  • 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-06-11T15:50:40+00:00Added an answer on June 11, 2026 at 3:50 pm

    Your inheritances are private, which prevents conversion from a pointer to a derived class to a pointer to its base class. You probably want public inheritance:

    class CatEvent : public CatBondEvent
                     ^^^^^^
    

    Unless otherwise specified, access to members and base classes is private in classes defined using the class keyword, and public in classes defined using struct.

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

Sidebar

Related Questions

I have been sharing database variables using the following code: Namespace DataAccessVariables Public Class
I have the following (C#) code namespace A { public interface IX { bool
I have the following code: Public Class Form1 Private Function Step1_Execute() As Boolean Return
I have the following code #include <iostream> using namespace std; class Object { public:
I have the following C# code: namespace ISeeOptic.BL { public abstract class Process {
I have the following code namespace A { [DataContract] public class CustomClass {} }
Suppose I have the following code: namespace x{ class X{ virtual void x(){} }
I have the following code: [DataContract(Namespace = )] public class User { [DataMember] public
I have the following C# code. namespace MyMath { public class Arith { public
I have the following code: using System.Configuration; namespace test { public partial class MyService

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.