Hello,
I'm trying to make an array with my own class as the ElementType.
I've read the docs for array, and it says "it must have a copy constructor and assignment operator". I think that's what I've done, but I'm getting the following errors...
error: ‘OtherClass::OtherClass(const OtherClass&)’ cannot be overloaded error: with ‘OtherClass::OtherClass(const OtherClass&)’ error: ‘OtherClass& OtherClass::operator=(const OtherClass&)’ cannot be overloaded error: with ‘OtherClass& OtherClass::operator=(const OtherClass&)’
Am I doing something silly? I tried looking at the Rectangle class for inspiration as it can be used as Array<Rectangle>
//---------------------------------
class OtherClass : public Component
{
public:
OtherClass() {}
~OtherClass() {}
OtherClass& operator= (const OtherClass& other) noexcept
{
return *this;
}
OtherClass (const OtherClass& other) noexcept
{
}
private:
void resized() {}
void paint(Graphics& g) {}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OtherClass)
};
//---------------------------------
class BaseClass : public Component
{
public:
BaseClass()
{
OtherClass oc;
myArray.add(oc);
}
~BaseClass() {}
private:
void resized() {}
void paint(Graphics& g) {}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BaseClass)
Array<OtherClass> myArray;
};