redeclared as different kind of symbol ,undefined reference to `__objc_class_name_Rectangle12'


||=== RTest, Debug ===|
D:\workspace\IOS\RTest\main.m|3|error: 'Rectangle' redeclared as different kind of symbol|
d:\app\ios\gnustep\bin\..\lib\gcc\mingw32\4.6.1\..\..\..\..\include\wingdi.h|2956|error: previous declaration of 'Rectangle'|
D:\workspace\IOS\RTest\main.m|16|error: 'Rectangle' redeclared as different kind of symbol|
d:\app\ios\gnustep\bin\..\lib\gcc\mingw32\4.6.1\..\..\..\..\include\wingdi.h|2956|error: previous declaration of 'Rectangle'|
D:\workspace\IOS\RTest\main.m||In function 'main':|
D:\workspace\IOS\RTest\main.m|41|error: 'myRect' undeclared (first use in this function)|
D:\workspace\IOS\RTest\main.m|41|note: each undeclared identifier is reported only once for each function it appears in|
D:\workspace\IOS\RTest\main.m|41|warning: invalid receiver type '' [enabled by default]|
D:\workspace\IOS\RTest\main.m|41|error: cannot convert to a pointer type|

||=== Build finished: 7 errors, 1 warnings ===|


類名重復,如果自己寫的類名沒有重復,則可能是根系統函數沖突.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

obj\Debug\main.o:main.m:(.data+0xb4)||undefined reference to `__objc_class_name_Rectangle12'|

錯將Rectangle12.m引入成了Rectangle12.h


接口和實現類分

好像OBJ-C里的實現好像不跟JAVA一樣,是單實現的,因為不可以給實現類寫名字(或許是我沒有發現).


其實也不算,這里面可以@interface A:NSObject

@interface B:A

@implementation B

{

//code here

}


@interface C:A

@implementation C

{

}

@interface D:B

@implementation D

{

}

------------------------------------------------------------------------------------------

ok,這好像是所謂的分類(categroy)機制

允許以模塊方式向現有類定義添加新方法,也就是,不必經常給同一接口和實現文件增加新定義.當想要對你沒有源代碼訪問權限的類添加新定義時,這特別方便.(分類和協議)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM