什么时候冬天| 尿失禁是什么症状| 黑皮肤适合穿什么颜色的衣服| 大家闺秀是什么生肖| 福州有什么好吃的| 金樱子配什么才壮阳| 为什么香蕉不能放冰箱| 儿童过敏性皮炎用什么药膏| 埋没是什么意思| 孕妇喝什么茶对胎儿好| 属狗的幸运色是什么颜色| 喝酒胃出血是什么症状| 考试前吃什么好| 五月七号是什么星座| 薄荷叶泡水喝有什么好处| 斑点狗是什么品种| 看淡是什么意思| 猪咳嗽用什么药效果好| 火龙果不能和什么一起吃| 拉肚子低烧是什么原因| 做梦梦见马是什么意思| 中午吃什么饭 家常菜| 白细胞阳性是什么意思| 脚为什么脱皮| 南瓜子有什么功效| 怀孕吃什么菜最有营养| 囹圄是什么意思| 葡萄糖阴性什么意思| 眩晕症是什么| 专技十三级是什么意思| 鹌鹑蛋不能和什么一起吃| 淋巴瘤是什么症状| 身份证上x代表什么| 吃什么可以增肥| 胎神什么意思| 手指起水泡是什么原因| maxrieny是什么品牌| 盐冻虾是什么意思| 为什么会做春梦| 腿痛挂什么科| 宝宝不爱吃饭是什么原因| 什么自如| 澄面粉是什么面粉| 脸上白一块一块的是什么原因| 5月24号是什么星座| 生男孩女孩取决于什么| 东北方向五行属什么| 砍是什么生肖| 一垒二垒三垒全垒打是什么意思| 什么的琴声| 宝宝细菌感染吃什么药| 接济是什么意思| 经常拉肚子是什么原因引起的| 氢氧化钠是什么| 拉锯战是什么意思| 二龙戏珠是什么意思| 生普属于什么茶| 病毒性疣是什么病| 养肝护肝吃什么最好| 士大夫什么意思| 肌肉酸痛挂什么科| 莺莺燕燕是什么意思| 老上火是什么原因造成的| 经常吃红枣有什么好处和坏处| 娇妻是什么意思| 脚麻吃什么药| 7月1日什么星座| 胃切除有什么影响| 黄连素又叫什么名字| 动脉硬化是什么意思| 洋葱什么时候收获| 豆蔻年华是什么意思| 九二共识是什么意思| 闭目养神什么意思| 三岁看小七岁看老是什么意思| 什么叫自负| 梦见蛇和鱼是什么意思周公解梦| 为什么同房后小腹疼痛| 过敏去医院挂什么科| 男人为什么喜欢吃奶| 舌头热灼是什么原因| 肝有钙化灶是什么意思| 芝士和奶酪有什么区别| 宫颈肥大伴纳氏囊肿是什么意思| 神经官能症吃什么药| 肝火旺吃什么食物好| 磨豆浆是什么意思| 子宫内膜厚有什么危害| 全身水肿是什么原因引起的| 腰肌劳损是什么原因造成的| 吃什么东西对肺部好| 脾虚胃热吃什么中成药| 滞留是什么意思| 大小脸去医院挂什么科| 鼻尖发红是什么原因| 流鼻涕是什么原因| 儿童内分泌科检查什么| 早上打碎碗是什么兆头| 水生木是什么意思| 有什么功效| 90年属什么生肖| 穿孔是什么意思| 医院医务科是干什么的| 菠萝为什么要泡盐水| 中秋节适合吃什么菜| 附耳是什么意思| 看牙齿挂什么科| 女生的阴道长什么样| 月经期间适合做什么运动| 绿豆煮出来为什么是红色的| 甲钴胺是什么| eps是什么意思| 白带黄是什么原因| 势利眼的人有什么特征| ecg是什么意思| 心属于五行属什么| 禾花鱼是什么鱼| 铁公鸡是什么意思| 女票什么意思| 指甲变紫色是什么原因| clarks是什么牌子| 五行金代表什么| torch什么意思| 氧化钠是什么| 月经老是推迟是什么原因| 尿素氮是什么| 马马虎虎指什么生肖| 绿豆什么时候收获| 男生留什么发型好看| 阴虚吃什么食补最快| 什么什么不周| 赤子之心什么意思| 花花世界不必当真是什么歌| 什么是室性早搏| 为什么会打鼾| 认命是什么意思| 电饭锅内胆什么材质好| 精液偏黄是什么原因| 整装是什么意思| 话说多了声音嘶哑是什么原因| 心悸什么意思| 舌苔厚发白是什么原因| 牙医靠什么吃饭| 坐围和臀围有什么区别| 胃糜烂要吃什么药| xxl是什么尺码| 吉尼斯是什么意思| 25周岁属什么生肖| 载脂蛋白b偏低是什么意思| fc什么意思| 二氧化碳是什么东西| jeans什么意思| 医学hr是什么意思| 为什么经常做梦| 优生优育检查什么项目| 人参泡酒有什么功效和作用| 凉皮是用什么做的| 精尽人亡什么意思| 小孩流鼻血吃什么好| 为什么做b超要憋尿| 格格是什么身份| 打太极拳有什么好处| 葫芦娃的爷爷叫什么| 看舌头应该挂什么科| 无是什么意思| 人长寿的秘诀是什么| mra是什么检查| l代表什么意思| 为什么脸一边大一边小| 小龙虾吃什么食物| 什么是间质瘤| 凌晨6点是什么时辰| 老母鸡煲汤放什么食材补气补血| 每天流鼻血是什么原因| 孕妇梦见坟墓是什么预兆| 富字五行属什么| 黄埔军校现在是什么学校| 狗肚子有虫子吃什么药| 晁盖的绰号是什么| 轻度异常脑电图是什么意思| seeya是什么意思| 天秤和什么星座最配| 青霉素v钾片治什么病| 来月经适合吃什么水果| 全身皮肤瘙痒是什么原因引起的| 孕妇能吃什么水果最好| 二次元文化是什么意思| 什么是冬虫夏草| 锁骨是什么位置| 尿酸高会引起什么病| 坏血病的症状是什么| 朱砂有什么作用与功效| 容易头晕是什么原因| 火烧云是什么意思| 动土是什么意思| lsil什么意思| 血红蛋白低吃什么补最快| 米为什么会生虫| 血肌酐高吃什么食物| 周传雄得了什么病| 垢是什么意思| 见血封喉什么意思| 7月14日是什么日子| 慌张的近义词是什么| 脚痒脱皮是什么原因| 香槟酒属于什么酒| 86年属虎是什么命| 宫腔内囊性回声是什么意思| 7月八号是什么星座| 金的部首是什么| 火箭军是干什么的| 罹患率是什么意思| 利字五行属什么| 科技皮是什么皮| 净身出户什么意思| 同房出血是什么原因造成的| 南极和北极有什么区别| 山羊吃什么| 抗核抗体是检查什么病| 假小子是什么意思| 荆条是什么意思| 翻身是什么意思| amazon是什么意思| 心率过快是什么原因| 如何知道自己是什么星座| 川芎治什么病最好| 政治家是什么意思| 丝瓜吃了有什么好处| 梦见坐飞机是什么预兆| 韫字五行属什么| 同房肚子痛是什么原因| 乳腺增生吃什么食物好| 金字旁成是什么字| 排卵期后是什么期| 为什么总是想吐| 风林火山是什么意思| 锶是什么意思| 大肝功能是检查什么| 茉莉花什么时候开花| 啧啧啧什么意思| 吃什么长骨头最快| 金牛座和什么座最配| 举人是什么意思| 宫颈转化区三型是什么意思| 口臭吃什么药效果最好| 殁年是什么意思| 灵芝孢子粉什么时候吃最好| 寒疾现代叫什么病| 八府巡按是什么官| 下眼皮跳是什么原因| 18岁是什么生肖| 婴儿感冒吃什么药| 纸上谈兵是什么生肖| 翘首以盼是什么意思| 爆缸是什么意思| jvc是什么牌子| 什么是经络| 脑袋进水什么意思| progress什么意思| 脂肪肝吃什么水果好| 心脏不好吃什么水果好| 在家里做什么能赚钱| 夜长梦多是什么意思| 甲状腺结节吃什么盐| 百度Jump to content

同居财产被判还拒不执行 法院强制执行显威力

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by 58.110.9.82 (talk) at 09:33, 29 December 2024 (Undid revision 1265923741 by 216.247.92.107 (talk)). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
百度 报道称,关于分割的权益之一下扎库姆油田,中石油新取得10%,以印度石油天然气公司(ONGC)为中心的印度企业联盟取得10%,意大利国家碳化氢公司(ENI)取得5%。

A method in object-oriented programming (OOP) is a procedure associated with an object, and generally also a message. An object consists of state data and behavior; these compose an interface, which specifies how the object may be used. A method is a behavior of an object parametrized by a user.

Data is represented as properties of the object, and behaviors are represented as methods. For example, a Window object could have methods such as open and close, while its state (whether it is open or closed at any given point in time) would be a property.

In class-based programming, methods are defined within a class, and objects are instances of a given class. One of the most important capabilities that a method provides is method overriding - the same name (e.g., area) can be used for multiple different kinds of classes. This allows the sending objects to invoke behaviors and to delegate the implementation of those behaviors to the receiving object. A method in Java programming sets the behavior of a class object. For example, an object can send an area message to another object and the appropriate formula is invoked whether the receiving object is a rectangle, circle, triangle, etc.

Methods also provide the interface that other classes use to access and modify the properties of an object; this is known as encapsulation. Encapsulation and overriding are the two primary distinguishing features between methods and procedure calls.[1]

Overriding and overloading

[edit]

Method overriding and overloading are two of the most significant ways that a method differs from a conventional procedure or function call. Overriding refers to a subclass redefining the implementation of a method of its superclass. For example, findArea may be a method defined on a shape class,[2] triangle, etc. would each define the appropriate formula to calculate their area. The idea is to look at objects as "black boxes" so that changes to the internals of the object can be made with minimal impact on the other objects that use it. This is known as encapsulation and is meant to make code easier to maintain and re-use.

Method overloading, on the other hand, refers to differentiating the code used to handle a message based on the parameters of the method. If one views the receiving object as the first parameter in any method then overriding is just a special case of overloading where the selection is based only on the first argument. The following simple Java example illustrates the difference:

Accessor, mutator and manager methods

[edit]

Accessor methods are used to read the data values of an object. Mutator methods are used to modify the data of an object. Manager methods are used to initialize and destroy objects of a class, e.g. constructors and destructors.

These methods provide an abstraction layer that facilitates encapsulation and modularity. For example, if a bank-account class provides a getBalance() accessor method to retrieve the current balance (rather than directly accessing the balance data fields), then later revisions of the same code can implement a more complex mechanism for balance retrieval (e.g., a database fetch), without the dependent code needing to be changed. The concepts of encapsulation and modularity are not unique to object-oriented programming. Indeed, in many ways the object-oriented approach is simply the logical extension of previous paradigms such as abstract data types and structured programming.[3]

Constructors

[edit]

A constructor is a method that is called at the beginning of an object's lifetime to create and initialize the object, a process called construction (or instantiation). Initialization may include an acquisition of resources. Constructors may have parameters but usually do not return values in most languages. See the following example in Java:

public class Main {
    String _name;
    int _roll;

    Main(String name, int roll) { // constructor method
        this._name = name;
        this._roll = roll;
    }
}

Destructor

[edit]

A Destructor is a method that is called automatically at the end of an object's lifetime, a process called Destruction. Destruction in most languages does not allow destructor method arguments nor return values. Destructors can be implemented so as to perform cleanup chores and other tasks at object destruction.

Finalizers

[edit]

In garbage-collected languages, such as Java,[4]: 26, 29  C#,[5]: 208–209  and Python, destructors are known as finalizers. They have a similar purpose and function to destructors, but because of the differences between languages that utilize garbage-collection and languages with manual memory management, the sequence in which they are called is different.

Abstract methods

[edit]

An abstract method is one with only a signature and no implementation body. It is often used to specify that a subclass must provide an implementation of the method, as in an abstract class. Abstract methods are used to specify interfaces in some programming languages.[6]

Example

[edit]

The following Java code shows an abstract class that needs to be extended:

abstract class Shape {
    abstract int area(int h, int w); // abstract method signature
}

The following subclass extends the main class:

public class Rectangle extends Shape {
    @Override
    int area(int h, int w) {
        return h * w;
    }
}

Reabstraction

[edit]

If a subclass provides an implementation for an abstract method, another subclass can make it abstract again. This is called reabstraction.

In practice, this is rarely used.

Example

[edit]

In C#, a virtual method can be overridden with an abstract method. (This also applies to Java, where all non-private methods are virtual.)

class IA
{
    public virtual void M() { }
}
abstract class IB : IA
{
    public override abstract void M(); // allowed
}

Interfaces' default methods can also be reabstracted, requiring subclasses to implement them. (This also applies to Java.)

interface IA
{
    void M() { }
}
interface IB : IA
{
    abstract void IA.M();
}
class C : IB { } // error: class 'C' does not implement 'IA.M'.

Class methods

[edit]

Class methods are methods that are called on a class rather than an instance. They are typically used as part of an object meta-model. I.e, for each class, defined an instance of the class object in the meta-model is created. Meta-model protocols allow classes to be created and deleted. In this sense, they provide the same functionality as constructors and destructors described above. But in some languages such as the Common Lisp Object System (CLOS) the meta-model allows the developer to dynamically alter the object model at run time: e.g., to create new classes, redefine the class hierarchy, modify properties, etc.

Special methods

[edit]

Special methods are very language-specific and a language may support none, some, or all of the special methods defined here. A language's compiler may automatically generate default special methods or a programmer may be allowed to optionally define special methods. Most special methods cannot be directly called, but rather the compiler generates code to call them at appropriate times.

Static methods

[edit]

Static methods are meant to be relevant to all the instances of a class rather than to any specific instance. They are similar to static variables in that sense. An example would be a static method to sum the values of all the variables of every instance of a class. For example, if there were a Product class it might have a static method to compute the average price of all products.

A static method can be invoked even if no instances of the class exist yet. Static methods are called "static" because they are resolved at compile time based on the class they are called on and not dynamically as in the case with instance methods, which are resolved polymorphically based on the runtime type of the object.

Examples

[edit]
In Java
[edit]

In Java, a commonly used static method is:

Math.max(double a, double b)

This static method has no owning object and does not run on an instance. It receives all information from its arguments.[2]

Copy-assignment operators

[edit]

Copy-assignment operators define actions to be performed by the compiler when a class object is assigned to a class object of the same type.

Operator methods

[edit]

Operator methods define or redefine operator symbols and define the operations to be performed with the symbol and the associated method parameters. C++ example:

#include <string>

class Data {
 public:
  bool operator<(const Data& data) const { return roll_ < data.roll_; }
  bool operator==(const Data& data) const {
    return name_ == data.name_ && roll_ == data.roll_;
  }

 private:
  std::string name_;
  int roll_;
};

Member functions in C++

[edit]

Some procedural languages were extended with object-oriented capabilities to leverage the large skill sets and legacy code for those languages but still provide the benefits of object-oriented development. Perhaps the most well-known example is C++, an object-oriented extension of the C programming language. Due to the design requirements to add the object-oriented paradigm on to an existing procedural language, message passing in C++ has some unique capabilities and terminologies. For example, in C++ a method is known as a member function. C++ also has the concept of virtual functions which are member functions that can be overridden in derived classes and allow for dynamic dispatch.

Virtual functions

[edit]

Virtual functions are the means by which a C++ class can achieve polymorphic behavior. Non-virtual member functions, or regular methods, are those that do not participate in polymorphism.

C++ Example:

#include <iostream>
#include <memory>

class Super {
 public:
  virtual ~Super() = default;

  virtual void IAm() { std::cout << "I'm the super class!\n"; }
};

class Sub : public Super {
 public:
  void IAm() override { std::cout << "I'm the subclass!\n"; }
};

int main() {
  std::unique_ptr<Super> inst1 = std::make_unique<Super>();
  std::unique_ptr<Super> inst2 = std::make_unique<Sub>();

  inst1->IAm();  // Calls |Super::IAm|.
  inst2->IAm();  // Calls |Sub::IAm|.
}

See also

[edit]

Notes

[edit]
  1. ^ "What is an Object?". oracle.com. Oracle Corporation. Retrieved 13 December 2013.
  2. ^ a b Martin, Robert C. (2009). Clean Code: A Handbook of Agile Software Craftsmanship. Prentice Hall. p. 296. ISBN 978-0-13-235088-4.
  3. ^ Meyer, Bertrand (1988). Object-Oriented Software Construction. Cambridge: Prentice Hall International Series in Computer Science. pp. 52–54. ISBN 0-13-629049-3.
  4. ^ Bloch, Joshua (2018). "Effective Java: Programming Language Guide" (third ed.). Addison-Wesley. ISBN 978-0134685991.
  5. ^ Albahari, Joseph. C# 10 in a Nutshell. O'Reilly. ISBN 978-1-098-12195-2.
  6. ^ "Abstract Methods and Classes". oracle.com. Oracle Java Documentation. Retrieved 11 December 2014.

References

[edit]
狗为什么怕猫 辅酶q10什么时间吃最好 国家电网是什么编制 牛欢喜是什么 验尿白细胞高是什么原因
胚由什么组成 眼底出血用什么药最好 舌头开裂是什么原因 怀挺是什么意思 俱往矣是什么意思
淡盐水是什么水 金匮肾气丸有什么功效 猪朋狗友是什么意思 眼袋肿是什么原因 7月八号是什么星座
求人办事送什么礼物好 人死后为什么要盖住脸 吃什么容易瘦 耵聍栓塞是什么意思 确立是什么意思
孩子注意力不集中缺什么微量元素hcv8jop6ns3r.cn 结婚年数代表什么婚hcv8jop8ns7r.cn 垂爱是什么意思hcv8jop5ns8r.cn 六味地黄丸的功效是什么xjhesheng.com 申遗是什么意思hcv7jop5ns3r.cn
hi是什么酸hcv7jop5ns3r.cn 为什么会得脑血栓hcv8jop3ns9r.cn 喉咙肿瘤有什么症状hcv8jop3ns0r.cn 凯莉包是什么牌子hcv8jop6ns4r.cn 生肖羊和什么生肖相冲hcv8jop2ns2r.cn
什么是高危性行为hcv9jop2ns0r.cn 女性掉发严重是什么原因aiwuzhiyu.com 手术后吃什么最有营养hcv8jop3ns3r.cn 孕晚期血糖高对胎儿有什么影响aiwuzhiyu.com 疑神疑鬼是什么意思hcv8jop1ns0r.cn
chihiro是什么意思hcv9jop5ns1r.cn 所什么无什么adwl56.com 吃多了拉肚子是什么原因bjcbxg.com 日龙包是什么意思hcv9jop6ns8r.cn 手掌很红是什么原因wuhaiwuya.com
百度