What is difference between these two.I google it down but could not find the satisfied answer.For example java is a oop(Object oriented programming) but not pure oop(was written on some sites).Can anybody explain?
-
Java enforces OOP (I.e. everything is in classes) whereas C++ is not specifically a OOP language, i.e. you can do things in C++ that does not require any kind of OOP but it's supported. Is this what you mean?Phorce– Phorce2015-02-23 11:40:06 +00:00Commented Feb 23, 2015 at 11:40
-
2In a pure OO language, everything is an object, and every action is taken through them (Smalltalk, for instance). In a language like Java, there are other data types, primitives, and it is possible to have static members, which are called (or should be, at least) on a class, not on an object.Stultuske– Stultuske2015-02-23 11:40:59 +00:00Commented Feb 23, 2015 at 11:40
-
@ Phorce:-In java everything is not in classes.F.e int float(I know there are wrapper classes).Secondly data base in java is on in oops(Unless u choose hibernate).Geek– Geek2015-02-23 11:42:20 +00:00Commented Feb 23, 2015 at 11:42
-
Watch this video you'll really find a different explanation of what OO really means.Sriram Sakthivel– Sriram Sakthivel2015-02-23 11:42:36 +00:00Commented Feb 23, 2015 at 11:42
-
@iasias: yes, everything is in classes, but "in a class" does not mean "in an object". also, that's not what he meant. he didn't say a float IS a class, he said floats are used in classes (but I agree with you, his point was vague and incomplete at best)Stultuske– Stultuske2015-02-23 11:43:54 +00:00Commented Feb 23, 2015 at 11:43
|
Show 4 more comments
3 Answers
Typically, in a pure OO language everything accessable in the language is an object (where even the classes that define objects can be object instances of meta-classes which in turn can be object instances of themselves). In Java and C++ there are basic language elements that aren't objects: most notably the primitive data types (or built-in types) such as int, float, char etc.
3 Comments
Joseph Mansfield
Better to say they're not class types - in C++, an object is any region of memory with a type, which includes
ints, floats, chars, etc.Paul Evans
@JosephMansfield OK, but the C++ standard's use of the word "object" is very different to the classical OO use of the word.
Joseph Mansfield
Sure, so describing it in terms of "classes", which basically has the same meaning across both example languages, is probably clearer. Or just clarify that you mean the OOP meaning of "object".
In a purely object-oriented language, everything is an object. However, in object-oriented languages, you may have non-object variables (e.g. static variables).
1 Comment
juanchopanza
Why would a static variable be of non-object type?