I got the above error at the mapping 'candidate'
pragma solidity ^0.4.22;
contract Election {
struct Candidates {
string name;
uint voteCount;
}
struct voter {
bool authorized;
bool voted;
uint vote;
}
address public owner;
string public electionName;
mapping(address => voter) public voters;
Candidate[] public candidates;
uint public totalVotes;
modifier ownerOnly() {
require(msg.sender == owner);
_;
}
function electionName(string _name) public {
owner = msg.sender;
electionName = _name;
}
function addCandidate(string _name) ownerOnly public {
candidates.push(Candidate(_name, 0));
}
function getNumCandidate() public view returns(uint) {
return candidates. length;
}
function authorize( address _person) ownerOnly public{
voters[_person].authorized = true;
}
function vote(uint voteIndex) public {
require(!voters[msg.sender].voted);
require(voters[msg.sender].authorized);
voters[msg.sender].voted = true;
voters[msg.sender].voteIndex = _voteIndex;
candidates[_voteIndex].voteCount += 1;
selfdestruct(owner);
}
}
Error
browser/Election.sol:22:5: DeclarationError: Identifier not found or not unique.
Candidate[] public candidates;
^-------^
Candidatesbut you are trying to refer it asCandidate. – Mikhail Vladimirov Mar 26 '19 at 06:57