开发者

Can you upcast in objective-c and how?

开发者 https://www.devze.com 2023-03-23 05:02 出处:网络
Can you upcast in objective-c?if so how? C# example: \"Asset\" is the base class. Stock msft = new Stock();

Can you upcast in objective-c? if so how?


C# example:

"Asset" is the base class.

Stock msft = new Stock(); 
Asset a = msft;            //开发者_如何学Goupcast


You mean typecast a subclass object to the type of a superclass? Sure - Objective-C has very liberal typecasting rules, just like C.

Superclass *superclassObject = (Superclass *)subclassObject;
0

精彩评论

暂无评论...
验证码 换一张
取 消