I want to use foo array of objects in all of Spam methods.
#include "spam.h"
class Foo: public Bar
{
public:
Foo(Layer* layer)
int getNumber() const;
// Something else
};
class Spam: public Layer
{
Spam();
// some methods
private:
Bar** foo; //here is the problem
};
This method (of course with one *) worked for me when I was creating one object.
void Spam::fun1()
{
Bar **foo = new Bar*[1];
foo[0] = new Foo(this);
//foo[1] = new Foo(this);
//foo[1]->getNumber(); // works correctly
}
void Spam::fun2()
{
//foo[1]->getNumber(); // foo[1] and foo[2] are NULL
foo[0]->getNumber(): // not working at all
}
But even I use Bar** foo or Bar** foo[2], Xcode shows me that I created new pointer to object.
[edit]I commented out wrong code example, my oversight, thanks guys.