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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:14:56+00:00 2026-05-25T11:14:56+00:00

I have classes A , B , C , D and the following hierarchy:

  • 0

I have classes A, B, C, D and the following hierarchy:

class A {
    B* b;
};

class B {
    C<D>* c;
};

template <class T>
class C<T> {
    list<T*> ds;
};

class D {
};

I allocate A first as an A* member inside a base class, using new A(). Within A I allocate b using new B(). Within B I allocate c using new C<D>().

As soon as I attempt to call ds.size() the program crashes. An EXC_BAD_ACCESS arises inside ds when it tries to call its begin() method within size().

Do you know why this would happen? I’ve been using C++ for a few years but this is my first foray into using pointers within standard containers, so maybe I’m missing something obvious.

  • 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-25T11:14:57+00:00Added an answer on May 25, 2026 at 11:14 am

    Your code, to my knowledge, should not care one way or another what the contents of list ds are. When you insert elements into containers and things like that you need to ensure that your element type supports all the necessary functionality (i.e. its assignable, copyable, and has the correct functions within it depending on which are required within that container class’ members).

    The .size function should just return the value of an internal member though, it doesn’t make much sense for that to be the thing that is crashing. Are you sure everything was properly allocated in your real code? it sounds to me like you just have an uninitialied pointer somewhere in the call-chain.

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

Sidebar

Related Questions

I have a class hierarchy with the following three classes: template<int pdim > class
I have an hierarchy of classes that looks like the following: class Critical {
I have the following classes: class Vigil < ActiveRecord::Base after_update :do_something_cool private def do_something_cool
I have the following hierarchy of classes class classOne { virtual void abstractMethod() =
I have the following class hierarchy in C++: class Base { virtual void apply()
I have a following class hierarchy: class Base{ .... virtual bool equal(Base *); }
I have the following hierarchy: Party is a base class, extended by Person and
I have following classes. class A { public: void fun(); } class B: public
I have the following classes public interface InterfaceBase { } public class ImplementA:InterfaceBase {
I have the following classes: Ingredients, Recipe and RecipeContent... class Ingredient(models.Model): name = models.CharField(max_length=30,

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.