Candidate::Candidate ()
{
}
Its not doing any thing.
Not writing it as it is can’t execute the line:
Candidate *list = new Candidate [10];
Why?
Error: no default constructor exists for the class "Candidate"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To allow your dynamic array allocation,
new Candidate[10], a default constructor ofCandidatemust be available. That is, it must be able to take no arguments. If you provide any of your own constructors forCandidate, regardless of how many arguments they take, the implicit default constructor that is usually defined automatically by the compiler will not be defined. You therefore have to provide it yourself, even if its body is empty. See §12.1/5:Your class would be fine as follows because the compiler will implicitly define a defaulted default constructor:
But as soon as you give it any other constructor, the implicit default constructor is not provided any more: