实例与实例之间的区别宾语 [英] difference between instance & object

查看:89
本文介绍了实例与实例之间的区别宾语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我实例和对象有什么区别我还不明白这两者之间的区别还有什么是抽象类和为什么要告诉我什么是抽象类?我们使用抽象类

3)什么是静态的以及为什么我们使用静态关键字

plz tell me what is the difference between instance and object i dont understand still the difference between these two

2) also tell me what is abstract class and why we use abstract class
3) what is static and why we use static keyword

推荐答案

它可能对你有帮助,



[ ^ ]

摘要 [ ^ ]

静态 [ ^ ]

抽象和密封的类和类成员 [ ^ ]



:)
It might help you,

Classes[^]
abstract[^]
static[^]
Abstract and Sealed Classes and Class Members[^]

:)


1)实例引用现有对象,其中作为一个对象是类型。



这样想,

汽车是对象,但实例是你驾驶的那个(相对于我驾驶的那个)。





2) abstract类允许继承的类使用多态(重载)。它还允许所有继承成员拥有的逻辑。



例如 Car 可能是抽象类但是 Sedan Sporty 将其用于父类。 汽车抽象类可能会彰显MPH的逻辑,因为它是相同的,无论是轿车还是运动型汽车。





3)静态意味着不需要实例。例如,前面提到的 Car abstract 类型实际上可以继承具有属性 WheelCount Vehicle Car s tatic 类型将导致4,其中 MotorCycle 将返回2.没有必要轿车实例跟踪此,因为所有 Car 的所有实例都具有相同的轮数。因此,可能会在抽象 静态 Car 构造函数或某些初始化方法中设置轮数的值。
1) An instance refers to an existing object, where as an object is the type.

Think of it this way,
A car is the object, but the instance is the one you drive (versus the one I drive).


2) An abstract class allows an inherited class to use polymorphism (overloading). It also allows logic that all inheritted members will have.

For example a Car may be the abstract class but Sedan and Sporty will use it for a parent class. The "Car" abstract class will likely impliment the logic for MPH as it is the same regardless of whether is is a Sedan or a Sporty car.


3) Static means no instance is necessary. For example the Car abstract type referred to earlier may actually inherit Vehicle which has a property WheelCount. The Car static type would result in 4 where as MotorCycle would return 2. There is no need to have the Sedan instance track this as all instances of all Cars will have the same wheel count. So one would likely set the value of the wheel count in an abstract static Car constructor or some initialization method.

object是类变量,内存分配给它的所有字段,但它们之间没有设置值,当所有字段都获得值赋值时,实例是运行时类的对象示例

public class cls

{

公共字符串名称{get; set;};

public string roll {get; set;};

}



然后对象在内存中表示为



名称指向内存



滚动点到内存



和实例代表内存为



名称指向内存,其中值Ganesh存储在名称中



滚动指向内存,其中值1存储在卷中
object is the class variable with memory assign to all its fields but no value set between them and instance is a object of class at run time when all fields get value assign example
public class cls
{
public string name{get;set;};
public string roll{get;set;};
}

then object represent in memory as

name point to memory

roll point to memory

and instance represent in memory as

name point to memory where value "Ganesh" is store in name

roll point to memory where value "1" is store in roll


这篇关于实例与实例之间的区别宾语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆