I am having trouble with what seems like a very simple concept. I have a class like such:
class Projectile
{
public:
int count;
int projectiles[1][3];
Projectile();
void newProjectile();
};
Projectile::Projectile()
{
count = 0;
}
void Projectile::newProjectile()
{
projectiles[0][0] = { 1, 2, 3 };
}
I am trying to set the values inside the projectiles array, and I must be doing this incorrectly. How can I go about dynamically adding a set of values into this property?
This isn’t correct. Initializer lists can only given at the point of declaration. You have to assign values independently to each location of the array elements.
std::vector<std::vector> twoDimArray;is what you want.