Declaration and implementation of the Oc-04-class

Source: Internet
Author: User
main.m//10-the Declaration and implementation of the "Mastering" class//.h for the declaration of the class,. M is the implementation of the class, + represents the class method static method,-represents the object method. The methods in the. h file are public and cannot be changed. Access domain in Variable 3: public,protected (subclass), private (this class). #import <foundation/foundation.h>//declare the class @interface Person:nsobject (parent class name) {    //Declare the attribute variable before you must underline it.    NSString * _name;    int _age;    float _weight;} Declaration Method-(void) eat;-(void) run;+ (void) breath; @end//Make an implementation class for humans the class  name of the class to implement which class is placed behind the @implementation. @implementation person//Implementation Method-(void) eat{    NSLog (@ "eat");} -(void) run{    NSLog (@ "Run and Run");} + (void) breath{    NSLog (@ "XXIXIXIXIX");} @endint Main (int argc, const char * argv[]) {    @autoreleasepool {        //Insert code        here ... NSLog (@ "Hello, world!");    }    return 0;}

Declaration and implementation of the Oc-04-class

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.