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 6619627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:59:36+00:00 2026-05-25T20:59:36+00:00

I encountered this problem using a third party library provided by a different group

  • 0

I encountered this problem using a third party library provided by a different group in the company (written in C++).

In the destructor of Observer, it detaches itself from all observables it subscribes to, this part makes sense to me. But in the destructor of Observable, it checks if the observable has any observer that’s still in it’s subscriber list. If so, throws an error.

I am going to put the fact that it intentionally throws an error in the destructor aside. Can someone try to explain to me the why the observable should expect no observers to outlive itself or is this just a bad design. If this is a bad design, when we are in circumstances when the observer outlives the observable, are there good ways to handle 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-05-25T20:59:37+00:00Added an answer on May 25, 2026 at 8:59 pm

    If the Observer has a pointer (or reference) to the Observable, and the Observable is destroyed, that pointer will be invalid. The author is just trying to avoid dangling references.

    There are three usual solutions, I think.

    One is to do exactly what this code does, perhaps calling abort() rather than throwing an exception in the destructor.

    Another is to have the Observable’s destructor de-register itself from any Observers.

    The last is to use “smart pointers” (e.g., a reference-counted shared_ptr) to guarantee that the Observable outlives any Observer.

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

Sidebar

Related Questions

When pasrsing XML using NSXMLParser, I encountered this problem when the parser received some
I've encountered this problem (while trying to add SQL Server Database (.mdf) file to
Hi i encountered this problem whereby when i initialized my String[], there seems to
Uhm I'm not sure if anyone has encountered this problem a brief description is
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
Has anyone encountered this error using SQL Server 2005 and Data access application blocks
I've encountered this issue on two different machines and can't figure out what the
I am working on this site and encountered the following problem when i opened
I encountered this problem when doing some enthusiastic programming. The problem can be expressed
I have encountered this problem: Depending on numbers from I want to create a

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.