| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 3953 人关注过本帖, 1 人收藏
标题:数据抽象
取消只看楼主 加入收藏
lz1091914999
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:四川
等 级:贵宾
威 望:37
帖 子:2011
专家分:5959
注 册:2010-11-1
收藏
得分:0 
回复 26楼 BlueGuy
其实面向对象最主要的是,继承和多态,比如在Thinking in C++中有一节是这样说的:
Evolution of C++ programmers (C++程序员的演变)
C programmers seem to acquire C++ in three steps.First,as simply a "better C",because C++ forces you to declare all functions before using them and is much pickier about how variables are used.You can often find the errors in a C program simply by compiling it with a C++ compiler.

The second step is "object-based"C++.This means that you easily see the code organization benefits of grouping a data structure together with the functions that act upon it, the value of constructors and destructors,and perhaps some simple inheritance.Most programmers who have been working with C for a while quickly see the usefulness of this because,whenever they create a library,this is exactly what they try to do.With C++,you have the aid of the compiler.

You can get stuck at the object-based level because you can quickly get there and you get a lot of benefit without much mental effort.It's also easy to feel like you're creating data types - you make classes and objects,you send messages to those objects, and everything is nice and neat.

But don't be fooled.If you stop here,you're missing out on the greatest part of the language, which is the jump to true object-oriented programming.You can do this only with virtual functions.

Virtual functions enhance the concept of type instead of just encapsulating code inside structures and behind walls,so they are without a doubt the most difficult concept for the new C++ programmer to fathom.However,they're also the turning point in the understanding of object-oriented programming.If you don't use virtual functions,you don't understand OOP yet.

My life is brilliant
2012-02-07 18:02
lz1091914999
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:四川
等 级:贵宾
威 望:37
帖 子:2011
专家分:5959
注 册:2010-11-1
收藏
得分:0 
面向过程程序设计中,编程时需要根据计算机的结构去思考问题,而并不是按照要解决的问题的结构去思考,程序员必须在机器模型(解空间)和实际要解决的问题(问题空间)之间建立联系。程序员必须努力进行这之间的对应,这实际上是程序设计之外的任务,它使得程序难以编写且维护费用昂贵,并且作为一种副效应,导致了面向对象(OOP)的产生,OOP针对要解决的问题建模(允许表示问题空间中的各个元素),这样就让程序员可以不必考虑对解空间之间的联系,减轻了程序员的负担,从而前进了一大步。

My life is brilliant
2012-02-19 17:14
快速回复:数据抽象
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.655044 second(s), 8 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved