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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:35:52+00:00 2026-06-02T21:35:52+00:00

Here is my code: typedef struct TItemSelector{ ItemSelectFrame* pItems[2]; } SItemSelector; class item {

  • 0

Here is my code:

typedef struct TItemSelector{
  ItemSelectFrame* pItems[2];
} SItemSelector;

class item {
  public:
  void expMethod();
  SItemSelector itemSelector_;
  UILayerButton* startBtn_;
};

void item::expMethod(){
startBtn_ = new UILayerButton();
for (i = 0; i < 3; i++) {
  itemSelector_.pItems[i] = new ItemSelectFrame();
}
startBtn_->callMethodA();
}

void UILayerButton::callMethodA()
{
  this->callMethodB();
}

void UILayerButton::callMethodB()
{

}

On this->callMethodB();, a “EXC_BAD_ACCESS” occoured.

After that I found a work-around:

class item {
  public:
  void expMethod();
  SItemSelector itemSelector_;
  SItemSelector itemSelector2_; // work around
  UILayerButton* startBtn_;
};

Then everything goes well… I just don’t know what happened, but callMethodB() is just an empty method, there’s nothing to do with it.

I’m using Apple LLVM 3.1, default setting.

UPDATE: Fixed my code.

  • 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-02T21:35:53+00:00Added an answer on June 2, 2026 at 9:35 pm

    In this code:

    for (i = 0; i < 3; i++) {
      itemSelector_.pItems[i] = new ItemSelectFrame();
    }
    

    you are writing over the end of itemSelector_.pItems because pItems is an array of length 2 but you are writing 3 elements.

    That then overwrites startBtn_ which happens to appear immediately after itemSelector_ in memory. And that explains the error when you subsequently read the now corrupted startBtn_.

    Either change your loop termination test, or increase the length of pItems. I can’t tell which one is the correct solution, but clearly you will know.

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

Sidebar

Related Questions

where is the mistake? My code here: typedef struct _box { char *dados; struct
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Here is code example class A{ int i; public: A(int i) : i(i) {}
Here is the code: .... typedef struct { int buf[10]; long head, tail; int
Here is the code #include<stdio.h> #include<sys/types.h> #include<stdlib.h> #include<pthread.h> typedef struct std_thread { char name[20];
Here's my code. #include<stdio.h> struct element { int value; char activity; }; typedef struct
I have a code: #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> typedef struct
can someone explain me the compilation error in this code: #include common.h typedef struct
In FastCGI, there is a pointer, envp, of struct FCGX_Request. Here is the code
Given the following code: typedef struct IntElement { struct IntElement *next; // use struct

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.