Home Iphone Objectivec Objective-C program with multiple parameter
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Objective-C program with multiple parameter

Advertisement
Objective-C enables programmer to use method with multiple parameter.

Objective-C program with multiple parameter

     

Objective-C enables programmer to use method with multiple parameter. These parameter can be of same type or of different type.
This is a sample program that shows sum of three numbers as output.

 

 

 

 

 MyClass.h
#import<Foundation/NSObject.h>
@interface MyClass:NSObject{
}

// declare method for more than one parameter
-(int) sum: (int) a andb: (int) b andc:(int)c;
@end

 MyClass.m
#import<stdio.h>
#import"MyClass.h"

@implementation MyClass
-(int) sum: (int) a andb: (int) b andc:(int)c;{
return a+b+c;
}
@end

 MyClass.m
#import<stdio.h>
#import"MyClass.m"
int main(){
MyClass *class = [[MyClass alloc]init];

printf("Sum is : %d",[class sum : 5 andb : 6 andc:10]);
[class release];
return ;
}


Output:

Sum is : 21
Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 17, 2005

Ask Questions?    Discuss: Objective-C program with multiple parameter   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com