I have a problem with the below code, specifically samplestruct2
struct samplestruct1 {
string name;
}
struct samplestruct2{
string name;
mapping (int => samplestruct1) s1s;
}
function createSampleStruct2(string name) {
samplestruct2 s2;
s2.name = name;
...
}
samplestruct2 s2
is giving me a warning : "uninitilized storage pointer"
I also tried samplestruct2 s2 = samplestruct2(name)
, it gives me also an error
Best Answer
Because
s2
is astruct
being instantiated in the function rather than the contract, solidity will make it astorage
member of the contract itself. This is unlike other primitive types which default tomemory
in the local scope of the function. The warning is a prompt to make a proper declaration. Either declares2
in the contract or usememory
to makes2
local tocreateSampleStruct2(string name)