English 中文(简体)
面向目标的方案拟订的C语文标题档案和可再使用性?
原标题:Header Files in C-language and Reusability of Object Oriented Programming?

在访谈中,我询问,由于重新使用是目标定向方案规划的主要优势之一,但也可以通过将标题档案列入C语来做到这一点? 因此,OOP的可再使用性和C Header档案有何区别?

最佳回答

如果通过“可使用性”来简单地暗示不必在每一代码模块中重复使用代码,那么C的主编就完成了这项任务,因为它允许在一个代码模块中界定与外部链接的功能和变数的申报在另一个代码模块中使用,而用户不必重新分类所有这些申报和(或)试图将通常属于图书馆一部分的每一项功能定义纳入每个代码模块。 因此,防止法典重复。

通过使用C++和Java等语文的遗产和多变性来制定面向目标的方案具有类似效果......你确定一个接口和(或)一个基流层一度,然后你可以通过另一个类别继承来“加入”。 此外,虚拟方法加上多形态,使你能够写出单一基级的职能,作为论据,但称之为实际上以衍生型类别界定的代码。 这基本上意味着你可在new<>/em>代码(即你的衍生类别)上填上old代码(即接受基类功能)。 例如,作为图书馆开发商,你可以界定一套基类/接口,用户可以从这些基类中提取,但依然有效使用这些基级功能,这些功能与接受基类论点的图书馆相同。 因此,你不会被迫重复这些职能,......这些职能仍然可以由你的“新”衍生课程来使用。

问题回答

基本上来说,没有本组织,而且只是使用包括头盔的负责人,你就可以利用现有职能,无需再次书写。

然而,如果你打算使用一种非常相似但略有不同的职能,那么你别无选择,只能书写。 您不能再利用这一情况下的原有职能,你必须写新字。

Advantage of OOP: If that function were a class instead, you can inherit from it, and only add a few small methods, so you can reuse most of the methods of the original class.

在此,重要的是不要混淆对欧佩组织和欧佩组织本身的语言支持。 重新使用的C码的共同做法是确定数据类型和功能,在标题档案中以数据类型操作,然后根据这些数据类型和功能实施功能。 当你仔细研究时,这是奥佩组织的执行,尽管没有适当的语言支持,因而不太稳定。 但是:一个分类数据结构和在这些数据结构上运行的C负责人文件是执行办公室。

因此,法典的可再使用性没有差别,只是对两个不同层次的看法。 禁飞组织是一个范例,在C背景下负责实施。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...