1
function Renting() public {

    checkUser[owner] = true;
    struct govt = Person(owner, 'Owner', 'Owner', 0, 'None',  new uint[](0), new uint[](0));

    addressToPerson[owner] = govt;
}

When I try to compile my contract I get an error saying Expected primary expression: struct govt = Person(owner, 'Owner', 'Owner', 0, 'None', new uint[](0), new uint[](0));

I referred once to Person in my contract

struct Person {

    address eth;
    string legalName;
    string email;
    uint aadhaar;

    string signTerms; 

    uint[] myOwned;
    uint[] myRented;
}
  • Which compiler version are you using? – Ann Kilzer Nov 17 at 12:47
  • I'm using 0.5.12 – Robin Kluysse Nov 17 at 12:51
1

Try this declaration for person:

Person memory govt = Person(owner, 'Owner', 'Owner', 0, 'None', new uint[](0), new uint[](0));

I'd recommend reading a little more about arrays in Solidity. You'll need to decide if you want your arrays to be memory or storage, which is very dependent on what your goals are. Since you've assigned them to size zero, please note that memory arrays cannot be resized. You'll also need to consider if you want your Person stored in memory or storage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.