In the parent class-(ID) initwithname :( nsstring *) aname
Sex :( nsstring *) asex
Age :( nsinteger) Aage
{
// Call the initialization method of the parent class
Self = [Super init]; // prevents initialization failure and assignment failure
If (Self ){
// Assign values to your instance variables
_ Name = aname;
_ Sex = asex;
_ Age = Aage;
}
Return self;
}
In the subclass (specified)-(ID) initwithname :( nsstring *) aname
Score :( float) ASCORE
Sex :( nsstring *) asex
Age :( nsinteger) Aage
Number :( nsstring *) anumber
{
// Super has only one function. It calls the parent class method.
// Call the parent class method and assign values to the instance variables of the parent class
Self = [Super initwithname: aname sex: asex age: Aage];
If (Self ){
// Assign values to your instance variables
_ Number = anumber;
_ Score = ASCORE;
}
Return self;
}
Other initialization methods (general)-(ID) initwithname :( nsstring *) aname
Score :( float) ASCORE
Number :( nsstring *) anumber
{
Return [self initwithname: aname score: ASCORE sex: nilage: 0 Number: anumber];
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.