<quote ref =
http://java.sun.com/docs/glossary.html#O>
"object
The principal building blocks of object-oriented programs. Each object
is
a
programming unit consisting of data (instance variables) and
functionality
(instance methods). See also class."
</quote>
It talks about methods not member functions.
[...]
///////////////////////////////////////////////////////////////////////////
//////////////
dam indenting again
///////////////////////////////////////////////////////////////////////////
///////////////
That to me is an ignorant reply. A method is generally accepted to mean
the
same thing as a member function(nonstatic respectively implied)
--"Method" is OOP term that i think was originally about Smalltalk style
--OOP where "method" was invoked when object received a message. Then
--Sun did screw all terminology up making quite C++ like member
--functions and calling them "methods". So perhaps at the moment indeed
--there are no difference anymore.
Now that is a good article of how contradicting and dim the views
about OOP are. I try to pick a quote there:
<quote>
By contrast, the object-oriented approach encourages the programmer to
place data where it is not directly accessible by the rest of the
program. Instead the data is accessed by calling specially written
'functions', commonly called methods, which are either bundled in with
the data or inherited from "class objects" and act as the
intermediaries for retrieving or modifying that data.
</quote>
Yes, so in C++ we have member functions inherited from class instead
of methods bundled in with the data. Class is type. There are no
reflection in C++ and no "class objects" in C++. Instead one can get
some sort of typeid that is a dim implementation-specific thing or
mess with templates to attach traits to types. Still that "member
function" of C++ is close enough to "method" of OOP to call it "OOP
support".
///////////////////////////////////////////////////////////////////////////
////////////////////////////
I don't see what you are trying to state here. I understand that text on
OOP
perfectly; It describes the concept of data protection and accessor
functions.
Why is it contradicting and dim?
--Because it say that the methods may be either inherited from classes
--(like in C++ or Java) or be bundled together with data (like in
--Javascript) and yet you "understand it perfectly" and yet you continue
--to argue that member functions are somehow bundled with data in C++.
--So it is too dim and contradicting and anyone can read what he wants
--from it.
No I'm not arguing that member functions are somehow bundled in with data in
C++.
When you speak of methods "bundled" with objects , this is an OOP concept.
--There are two different alternative styles: methods "bundled" with
--types of objects and methods "bundled" with data of objects. C++ is
--quite explicit about objects consisting of data (storage) and member
--functions being part of class (type).
OOP is a programming style(programming paradigm). You are highlighting
different ways of implementing OOP.
If the programming language supports OOP then it has mechanisms which
support this concept, it doesn't really matter what the underlying
technical
implementations are.
--It is not about underlying mechanics. It is about different styes of
--OOP.
I think OOP already is a programming style.I dont understand what you mean
by different styles of OOP.
The C++ language is defined in such a way that if a class declares a
nonstatic method then this method will be available as a member of an
object(instance of the class).
--You repeat and repeat that. It does not make that more true.
Do you mean you think its incorrect(not true)?
-- The objects of class type may have only "member subobjects" and "base
--subobjects" by C++ standard. If you need "method subobjects" then you
--perhaps make some "member subobjects" of functor type (with operator()
--() overloaded) or may be use boost::bind() to bind some functionality
--to object. Function pointers and member function pointers are also
--possibility but these have so nasty syntax that first novice
--maintainer will eyeball it for some hours and then run away crying.
--Member functions however are part of class and inherited from class
--and class is not object in C++.
To save repitition I define my meaning of 'object' from now on to mean: an
instance of class type, unless I state otherwise.
When you say "an object is not a class" you seem to completely dissassociate
the two terms(object and class). An object is a runtime entity, a class is
precompile time entity and these two entities are intimately related in C++.
A class is the template for an object(exception of statics) so any nonstatic
members declared in a class will also be member of an object of that
class-type.
Please can you explain why you have a problem with this analogy.
Note: deliberate use of method here to emphasise the association with OOP.
The C++ standard cannot fully define the mechanisms because it chooses to
leave this up to the implementation, for a good reason. If the C++
standard
was to try and define this for every possible and future computer system ,
it would need to be rewritten before it was drafted for comments.
--Actually C++ standard is grown so fat of quirks and details that there
--are not so lot of freedom in implementation like you seem to suggest.
--Borland does still compile only subset of C++ and for Microsoft it
--took years to get C++ to compile more or less.