I
imutate
I have a std::vector with each element being a class, I push_back
elements and then store values in the class object, later I look at
these objects and the values are null. In essence:
class celement
{
public:
int x[3];
...
class vec
{
public:
std::vector<celement> v;
...
void vec::addelement()
{
celement t;
v.push_back(t);
}
void vec::buildmono()
{
addelement();
v.end() -> x[0] = -1;
...
void vec::buildmono()
{
for (i = 0; i < 10; i++)
buildmono();
Later I look through v and none of x[0]s are -1 they are all 0.
for (i = 0; i < 10; i++)
cout << v.x[0] ..
If there is no obvious explanation then I can post more code.
elements and then store values in the class object, later I look at
these objects and the values are null. In essence:
class celement
{
public:
int x[3];
...
class vec
{
public:
std::vector<celement> v;
...
void vec::addelement()
{
celement t;
v.push_back(t);
}
void vec::buildmono()
{
addelement();
v.end() -> x[0] = -1;
...
void vec::buildmono()
{
for (i = 0; i < 10; i++)
buildmono();
Later I look through v and none of x[0]s are -1 they are all 0.
for (i = 0; i < 10; i++)
cout << v.x[0] ..
If there is no obvious explanation then I can post more code.