amf!! im sorry.. im just asking, i thought python have some similarity of c++ so i just people here in this forum... so if you dont like to help me.. fine!! thanks anyway......
It'd be much faster to state what they have in common
Taken from a python tutorial for C++ developers. basically the only thing they is the possibility of object oriented code. and that's only achieved in python through metaprogramming.
What? The only thing they have in common is the possibility of object oriented code??? And that's only achieved in Python through metaprogramming???
No and no.
What do they have in common? Both are general purpose languages that support elements of procedural, object-oriented and functional programming paradigms, easily mixing all three styles. Both have an ALGOL-based syntax.
Python is notable for enforcing block structure with whitespace (indentation).
C++ is notable for its backwards compatibility with the C language.
The two most noticeable differences are A) Python (CPython specifically) is an interpreted language whereas C++ is (typically) compiled, and B) Python is a dynamically-typed language while C++ is statically typed.
Various tools makes it easy extend Python with modules written in C++. And the CPython interpreter can be embedded in C++ applications.
Object Oriented is a style of programming, not a language feature. Just because you say animal.nomnomnom(cracker); instead of nomnomnom(&animal,cracker); doesn't mean that one is OO and the other is not. They are both OO.
rocketboy, actually, it's a programming style AND an language feature. In languages that do not support object orientation object oriented programming can usually only be done very superficially.
What do you mean by "superficially"? OO is enabled by the more generic feature of 'record types', that is data structures with non-homogenous types. And what particular feature would you say constitutes support for object orientation? Inheritance? The object.method syntax sugar? Perhaps operator overloading or templates? Or encapsulation? (which is easily obtainable in C; look at HWND or FILE*).
First of all, it would have to support objects. Which means entities with encapsulated data and methods to operate on that data.
For programming object oriented, it would also have to support inheritence and polymorphy, templates are not necessary (actually, templates have nothing to do with object orientation at all- at least not the C++ templates).
With HWND: it's just a number. I don't really get what you're getting at here. Neither FILE structs nor HANDLE's have anything to do with object oriented programming, so I don't really know what you're getting at here.
And you can emulate object orientation in procedural languages, but you can not program object oriented.
FILE structs are encapsulated. They are forward-declared, so even if you knew the members, you would not be able to access them. Furthermore it's actually better encapsulation than in C++, because a change to the members of FILE would not trigger recompilation of the code using it.
Inheritance and polymorphism are also used in supposedly non-OO languages. For example, the Event union in SDL uses polymorphism to support a variety of events to by stored in the same variable.
These examples show that OO is not a language feature. Many language features help achieve it, but the concepts are universally applicable.
EDIT: Also, methods are just syntax sugar for functions which take an object as an argument.