Protected微妙之出
来源:互联网 发布:java微服务框架 api 编辑:程序博客网 时间:2024/04/28 00:41
Protected说了那么多,估计还是有很多人分不清楚怎么用,下面给一个demo
public class LearnProtected { public string GetName() { Rat rat = new Rat(); rat.crow();//正常调用 Cat cat = new Cat();//类里面没有重写就没有办法让对象调用 return cat.crow(); //报错了,没有该方法了 } } public class Animal { protected string crow(string name) { return name; } } public class Cat:Animal { } public class Rat:Animal { public string crow() { string result = ""; result= crow("Rat"); //在类里面可以调用父类的Protcted方法 return result; } }
0 0
- Protected微妙之出
- 微妙
- 微妙
- shell heredoc 微妙之处
- 继承之Protected关键字
- 征服C指针之数组和指针的微妙关系
- 二叉树最大深度最小深度之微妙区别
- cpp反汇编之protected
- C++访问控制之protected
- usleep 微妙
- protected
- Protected
- protected
- protected
- protected
- 工薪族巧理财之定期存款中整存整取、零存整取、存本取息之间的微妙区别
- 深入浅出C++之private/public/protected
- 深入浅出C++之private/public/protected
- ffmpeg 的一些用法
- Android卸载程序之后跳转到指定的反馈页面
- 20-OC中NSFileManager的常见方法
- 待飞日记(第四天和第五天)
- unity 3D学习
- Protected微妙之出
- XML转义字符(转)
- 21-OC中的copy使用
- 异或的应用 及剑指offer 面试 40 数组中只出现一次的数字
- 更深层次的理解Context
- Spring init-method和destroy-method属性的使用
- 22-OC中通过block对NSArray中的数据进行排序
- php切割文件
- JQuery异步提交操作