tags:

views:

522

answers:

9

As i know that, in OOP we have to declare anything i.e variable, function.. etc inside the class like in java, but in c++ we can declare outside the class also...

is it the reason that, c++ is not fully OOP. or anything else.. anyone help me please...........

+6  A: 

Define fully OOP? There are as many opinions as people probably

Note as far as purity goes, IIRC all languages with valuetypes are not "pure" in the strict sense. No, boxing doesn't count.

Over the years, in discussion I've tried to go back to the core OOP features:

  • identity
  • Classification
  • polymorphism (not inheritance, since some OOP have no inheritance)
  • encapsulation

So if you can tell if two classes are not the same class (identity), you can make the classic "duck quacks" and "dog barks" example (to demonstrate inheritance/polymorphism and classification) and you can hide fields, you are pretty much there.

Applying it to all the languages is more difficult though. While I do get functional programming roughly, I'm not trained enough in the their near infinite jargon to judge all those functional-oop-imperative hybrids that are springing up,

Marco van de Voort
I'd even guess opinions > people. ;)
Adrian Grigore
Quite possibly... mine has changed a bit over the years :)
workmad3
@Adrian: especially if some of them have more than one user :)
Daniel Daranas
+11  A: 

Huh? C++ is a hybrid, multi-paradigm language. It is certainly not a "pure" object-oriented language, where "everything is an object" holds true. C++ supports classes, objects, encapsulation, and so on, but since it's also (more or less) backwards-compatible with a lot of C code, it cannot be "fully object-oriented".

unwind
+3  A: 

In C++ you don't HAVE to code using OOP, you can choose not to use it. Having said that, it's "fully OOP", OOP is just just not a requirement.

Sev
A: 

The main() function is not inside a class, so for this reason, one could argue that C++ is not fully OOP.

LeopardSkinPillBoxHat
Except that C++ does not require main to be a function.
anon
@Neil: Then how else can you declare main()?
the_drow
You can't declare main. The compiler is permitted to implement it as it sees fit. You are also (unlike in C) not permitted to call it, because it may not be a function.
anon
+7  A: 

Object-Oriented Programming is not definition of the language, it's definition of the programming, a program. I.e. one program in C++ can be OOP, and other can be not OOP.

What you can say is that C++ fully supports means of programming in OOP paradigm.

Delynx
A: 

One of the reason C++ is not fully OOP is the requirement of backward compatibility with a lot of C code. Built in types are not Objects in C++ as it is less efficient if they were. Remember, C++ first target audience were existing C programmers and efficiency was (is) a great concern.

However, C++ supports all the important features of OOP.

Related Link : www.research.att.com/~bs/oopsla.pdf

Aditya Sehgal
One could as well say Java isn't fully OOP because it supports valuetypes.
Marco van de Voort
If fully OOP == "everything should be an object", then yes java is also not fully OOP. In my opinion, everything should be an Object is a loose way to define OOP.
Aditya Sehgal
Note that the valuetype argument is just one I know from similar internal debates in our UUG. Not necessarily my opinion. IMHO the problem is in the question, not the answer
Marco van de Voort
Exactly. C++ satisfies enough OO Principles to qualify as fully OOP. I alaways figure that the valuetype argument is just a technicality or an implementation decision.
Aditya Sehgal
It keeps the Java and C# people of your neck :-)
Marco van de Voort
+3  A: 

not even java is a full OOP language.
in real OOP languages everything is an object, conditionals, loops, etc.

knittl
@knittl "not even java is a full OOP language"??? How? Then how about C#?
JMSA
@JMSA: no, c# falls in the same category as java, c++, etc. if you want a full OOP language have a look at [smalltalk](http://en.wikipedia.org/wiki/Smalltalk) and similar
knittl
A: 

Even though the question is somewhat ugly phrased I'm not really satisfied with all the answers provdided yet. I preffer to think of languages as "supporting a paradigm" and not "being in a paradigm". So, when does a language support a paradigm? When it is easy to write code that satisifies the requirements of the paradigm. How one comes to this conclusion? Consider the style linux filesystems are implemented. It is C-Code that clearly has OO properties. So, would you not consider this code to be OOP because C is not a OOP-language? I don't think so. (I guess some people will rightfully disagree as this seems to be amtter of opinion.) What does this imply for C++? Well, C++ has a lot of facilities for making it easier to program in a OO-Style, but it also provides you with a lot of means to rape the paradigm and write code that looks OO (because you use classes, inheritance private variables) but completly violates some other OO-principles (e.g. single responsibility, open-closed, uniform access).

I would conclude that C++ supports the OO-paradigm to some extent but is clearly inferior to some of the modern OO languages.

pmr
OOP modelling and OOP languages are not the same thing, as the C example demonstrates. Do you have a reference for those OO principles? I could only find the ones listed above. People add features "in the spirit of OO" all the time, but that can also be to create an unique selling point for their own so perfect language.
Marco van de Voort
Personally, if I talk about "OO principles" I mean the ones descriped in "Object-Oriented- Software Construction" by Bertrand Meyer. http://stackoverflow.com/questions/399656/are-there-any-rules-for-oop gives an overview as well.
pmr
A: 

The best answer I can offer is a link to B. Stroustrup's paper Why C++ is not just an Object Oriented Programming Language

Nemanja Trifunovic