objectice-c开门大吉

阅读更多
#import "MySquare.h"

int main(int argc,const char *argv[])
{
	MyRectangle *rec = [[MyRectangle alloc] initWidthHeight: 2 andHeight:5];
	[rec area];

	MySquare *squa = [[MySquare alloc] initWidthSize: 4];
	[squa area];

	if([squa isMemberOfClass: [MyRectangle class]])
	{
		printf("squa isMemberOfClass MyRectangle\n");
	}
	else
	{
		printf("squa not isMemberOfClass MyRectangle\n");
	}

	if([squa isKindOfClass: [MyRectangle class]])
	{
		printf("squa isKindOfClass MyRectangle\n");
	}
	else
	{
		printf("squa not isKindOfClass MyRectangle\n");
	}

	if([squa respondsToSelector: @selector(initWidthSize:)])
	{
		printf("squa respondsToSelector initWidthSize\n");
	}
	else
	{
		printf("squa not respondsToSelector initWidthSize\n");
	}


	[rec release];
	[squa release];
}


你可能感兴趣的:(C,C++,C#,Objective-C)