原帖由 "大菠萝" 发表:
我觉得C++不是一个C的扩展,而是一门崭新的语言,只是基本的语法和C相同,在C语言世界中,可能可以将
class A
{
public:
int member1,member2;
private:
int member3;
public:
void Function1();
}
用
..........
One of the issues in OOP that has become especially prominent since the introduction of C++ is whether all classes should ultimately be inherited from a single base class. In Java (as with virtually all other OOP languages except for C++) the answer is yes, and the name of this ultimate base class is simply Object. It turns out that the benefits of the singly rooted hierarchy are many. Feedback
All objects in a singly rooted hierarchy have an interface in common, so they are all ultimately the same fundamental type. The alternative (provided by C++) is that you don’t know that everything is the same basic type. From a backward-compatibility standpoint this fits the model of C better and can be thought of as less restrictive, but when you want to do full-on object-oriented programming you must then build your own hierarchy to provide the same convenience that’s built into other OOP languages. And in any new class library you acquire, some other incompatible interface will be used. It requires effort (and possibly multiple inheritance) to work the new interface into your design. Is the extra “flexibility” of C++ worth it? If you need it—if you have a large investment in C—it’s quite valuable. If you’re starting from scratch, other alternatives such as Java can often be more productive. Feedback
All objects in a singly rooted hierarchy (such as Java provides) can be guaranteed to have certain functionality. You know you can perform certain basic operations on every object in your system. A singly rooted hierarchy, along with creating all objects on the heap, greatly simplifies argument passing (one of the more complex topics in C++). Feedback
A singly rooted hierarchy makes it much easier to implement a garbage collector (which is conveniently built into Java). The necessary support can be installed in the base class, and the garbage collector can thus send the appropriate messages to every object in the system. Without a singly rooted hierarchy and a system to manipulate an object via a reference, it is difficult to implement a garbage collector. Feedback
Since run time type information is guaranteed to be in all objects, you’ll never end up with an object whose type you cannot determine. This is especially important with system-level operations, such as exception handling, and to allow greater flexibility in programming. Feedback
原帖由 "无双" 发表:
做一个系统
考虑的是怎样能更快更好的实现用户需求
并且设计实现更简单,就是从用户角度来考虑而不是从程序员角度考虑
做项目并不是为了表现程序员的某个编程技巧而是看整体结果
?.........
java的速度慢,我是比较有体会,我做过的通讯系统用c做的,一秒钟大概可以到1000条消息以上,而另外一个系统是用java做的,一秒钟大概只有30-50条这样,差别比较大;
原帖由 "Dasn" 发表:
C/C++;
菜刀/食品加工机;
做饭时喜欢用菜刀,因为砍的顺手了。呵呵~
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |