English 中文(简体)
奇怪的错误:EXC_BAD_ACCESS 我的班子
原标题:Strange errors: EXC_BAD_ACCESS in my class
  • 时间:2012-04-28 13:08:12
  •  标签:
  • c++
  • ios
  • llvm

我的守则是:

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.

之后,我找到了工作:

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

那么,一切都好了......。 我只不知道发生了什么,但<条码>电话:MethodB()只是一种空洞的方法,与它毫无关系。

I m 采用Amplus LLVM 3.1,设定违约。

UPDATE: 确定我的代码。

最佳回答

该法典规定:

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

页: 1 由于<代码>pItems是一系列长度的<代码>2,但您为:3内容。

接着,在<条码>后即刻露面的<条码>。 这解释了你后来读到现在腐败的<代码>启程Btn_时的错误。

修改了您的假体终止测试,或增加了<代码>p>的长度。 项目。 我可以告诉什么是正确的解决办法,但你显然知道。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签