I have a class I've created that represents a molecule and I would like to populate a 1D array with these molecules.
class Molecule {
public:
enum TypeReplicator {
p,
q,
s,
};
enum TypeComplex {
free,
occupied,
temp,
cata,
};
private:
double m_kppp{}; // last two letters stand for template/product
double m_kppq{};
double m_kpqq{};
double m_kpqp{};
double m_kqpp{};
double m_kqpq{};
double m_kqqq{};
double m_kqqp{};
int m_cor{}; // This is coordinate in 1D for now.
TypeReplicator m_typeRep{s};
TypeComplex m_typeComp{free};
double m_mutation_probability{};
public:
Molecule() = default;
Molecule(int cor, TypeReplicator typeR = s, TypeComplex typeC = free)
: m_kppp{1}, m_kppq{1}, m_kpqq{1}, m_kpqp{1}, m_kqpp{1}, m_kqpq{1},
m_kqqq{1}, m_kqqp{1}, m_cor{cor}, m_typeRep{typeR}, m_typeComp{typeC} {}
const TypeReplicator &getTypeReplicator() { return m_typeRep; }
int getCor() { return m_cor; }
};
When I create an array of this class object using
Molecule plane[512 * 512]{};
I get a address boundary error. I suspect it's something to do with my constructor definition. What's wrong?