Re: Structure and pointers
Quote:
Originally Posted by
zorro68
ElementData Propiedades[MaxElem] =
{
{ 1, "H" , "Hidrógeno" , "Hydrogen" , "Wasserstoff" },
{ 2, "He", "Helio" , "Helium" , "Helium"}
...
};
You define a new Propiedades variable here, so not only you don't initialize Elementos::Propiedades, but also you assign an address of a temporary object to p.
Do you reall want to store a copy of that table in every Elementos instance? I would define Propiedades as static.
Re: Structure and pointers
Quote:
You define a new Propiedades variable here, so not only you don't initialize Elementos::Propiedades, but also you assign an address of a temporary object to p.
I have proved this:
Code:
....
}*Propiedades[MaxElem],*p;
Code:
Propiedades[MaxElem]=new ElementData;
Propiedades[MaxElem] =
{
{ 1, "H" , "Hidrógeno" , "Hydrogen" , "Wasserstoff"},
{ 2, "He", "Helio" , "Helium" , "Helium"}
....
and i get a lot of syntax errors and i don't know why. Or this:
Code:
Propiedades[0]={ 1, "H" , "Hidrógeno" , "Hydrogen" , "Wasserstoff"};
Propiedades[1]={ 2, "He", "Helio" , "Helium" , "Helium"};
I get the same error.
Quote:
Do you reall want to store a copy of that table in every Elementos instance?
No, but i don't know how?
Quote:
I would define Propiedades as static.
How?
Re: Structure and pointers
I used an static variable Propiedades out of the class definition and works fine.
Thanks very much.