// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
contract s12 {
uint public age;
string public name;
bool rollno;
constructor() public {
rollno= false;
}
function setname(string memory newName) public {
name=newName;
}
function getname() public view returns (string){
return name;
}
function setAge(string memory newAge) public {
age=newAge;
}
function getAge() public view returns(uint){
return age;
}
}
Add a comment
|
1 Answer
Two remarks here:
In function getname(), you just need to add
memory
in the returned value:function getName() public view returns (string memory) {..}
You have a type mismatch in function setAge(), as you are assigning newAge (string) to age (uint). The newAge parameter should be
uint
as well.function setAge(uint newAge) public { age = newAge; }