1. js 其实是一个非面向对象的语言,通过对象的深浅复制完成继承2. 继承方法继承的方法有两种1)prototype 原型模式举个例子var Animal = function () { this.type = 'animal'; this.tmp = {name:'hehe'}; ...
分类:
编程语言 时间:
2015-04-28 01:46:36
阅读次数:
168
#include
using namespace std;
class Animal
{
private:
char name[20];
protected:
int age;
public:
void setName(char *name)
{
strcpy_s(this->name,name);
}
void setAge(int age)
{
this->age=age...
分类:
编程语言 时间:
2015-04-27 11:13:40
阅读次数:
188
package com.hengheng.scalaabstract class Animal { def walk(speed : Int) def breathe() = { println("Aninamal breathes.") }}trait Flyable { def...
分类:
其他好文 时间:
2015-04-26 13:48:05
阅读次数:
118
zoo = ('大象','老虎','狮子','北极熊')print('The animal number of the is ', len(zoo))print('The animal of the zoo are ',zoo)new_zoo = ('孔雀','鳄鱼',zoo)print('The ...
分类:
编程语言 时间:
2015-04-22 17:40:59
阅读次数:
120
多态的存在有三个必要条件:1.要有继承2.要有重写3.父类引用指向子类对象 1 class Animal { 2 private String name; 3 Animal(String name) {this.name = name;} 4 5 public void enjoy...
分类:
编程语言 时间:
2015-04-22 00:15:29
阅读次数:
128
继承/*
1.继承的好处:
1> 抽取重复代码
2> 建立了类之间的关系
3> 子类可以拥有父类中的所有成员变量和方法 2.注意点
1> 基本上所有类的根类是NSObject
*/
/********Animal的声明*******/
@interface Animal : NSObject
{
int _age;
double _weight;
}- (void)set...
分类:
其他好文 时间:
2015-04-18 13:07:16
阅读次数:
114
今天看到一篇博客讲解了几个JavaScript的技术点,感觉很实用。原地址:Javascript常见技术点 1、javascript面向对象中继承实现javascript面向对象中的继承实现一般都使用到了构造函数和Prototype原型链,简单的代码如下: function Animal...
分类:
编程语言 时间:
2015-04-17 21:48:03
阅读次数:
158
csdn没有在移动上布网,最近移动校园网登不上csdn,今天终于能登上了,小草鸟就写下最近在学的设计模式。
工厂估计也差不多是用的最多的了,对于工厂方法和抽象工厂比较容易混,笔者在这里说下自己的学习的一些理解。
工厂模式:
产品
对于工厂,当然是生产产品的了,当然我们得有产品类,为了扩展性良好,先定义一个产品接口
public interface Animal {
pub...
分类:
其他好文 时间:
2015-04-14 08:35:52
阅读次数:
184
C++类中成员变量的初始化有两种方式:
构造函数初始化列表和构造函数体内赋值
1 内部数据类型(char,int……指针等)
class Animal{public: Animal(int weight,int height): //A初始化列表 m_weight(weight), m_height(height) { }...
分类:
编程语言 时间:
2015-04-14 08:35:44
阅读次数:
161
1 #include 2 3 using namespace std; 4 5 class animal 6 { 7 public: 8 virtual void print_age(void)=0; 9 protected:10 int age;11 };12 class ...
分类:
其他好文 时间:
2015-04-12 15:58:41
阅读次数:
144