Ios-a+b Classic Questions

Source: Internet
Author: User

  main.m//  a+b//#import <Foundation/Foundation.h> #import "Calcultor.h" int main (int argc, const char * argv[]) {    calcultor * cal = [[Calcultor alloc]init];        [Cal Seta:10];    [Cal Setb:20];        int result = [cal add];    NSLog (@ "%d", result);        NSLog (@ "%d", [Cal Sub:10 Andb1:10]);    return 0;}
  calcultor.h//  a+b//#import <Foundation/Foundation.h> @interface calcultor:nsobject{    int _ A;    int _b;} /*set Get */@property int A; @property int b;-(int) add;-(int) sub: (int) A1 ANDB1: (int) B1; @end
  calcultor.m//  a+b//#import "Calcultor.h" @implementation calcultor-(ID) init{self    = [super init];    if (self! = nil)    {        _a = 0;        _b = 0;    }    return self;} -(int) add{    return _a + _b;    NSLog (@ "A+b");} -(int) sub: (int) A1 ANDB1: (int) B1; {    _a = A1;    _b = B1;    return _a + _b;} @end



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Ios-a+b Classic Questions

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.