I have always heard that C++ is not Object Oriented but rather "C with Classes". So, when I mentioned to an interviewer that C++ was not really object oriented, he asked me why I didn't consider it an OO language. I haven't done any C++ since University, and I didn't have much of an answer. Is C++ Object Oriented or not? and why?
相关问题
- how to define constructor for Python's new Nam
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Keeping track of variable instances
- Why does const allow implicit conversion of refere
相关文章
- 接口B继承接口A,但是又不添加新的方法。这样有什么意义吗?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
The term "object oriented" is too hazy to give a definite yes or no answer. I think you'll find the majority view is that C++ is an OO language, or at least that you can write in an OO way in C++. If you want a more definite answer, you'll have to ask a better defined question, such as:
Q: Does C++ have "object" (i.e. data fields + associated member functions) data types?
A: Yes.
Q: Does C++ have non-object data types?
A: Yes.
Q: Does C++ have non-member functions?
A: Yes.
If I am an interviewer asking you this question, I'm probably not caring about the yes/no answer - I really want to know what you understand about programming, and C++ or other languages. Are you just throwing out terms that you don't think about or understand, or do you actually consider carefully what you are doing and saying. So in this situation a good answer is
"I define Object oriented coding to be a, b, c, and d. I define an Object Oriented language as one which supports that definition, ie. permits me to (easily / uniformly / rigorously / other adjective ) develop code that fulfills those requirements. C++ delivers a,b,c, and partially on d. So I do ( don't ) consider C++ to be OO for those reasons."
For my personal definition, C++ is object-oriented enough, plus it supports other approaches.
Meh. Everybody has their own deinition of OOP. Alan Kay who invented the term OOP said: http://www.noulakaz.net/weblog/2007/02/12/true-meaning-of-oop/
By that definition even Java, C#, Python etc are not OO languages.
IMHO, these discussions are pointless.
C++ is an OO language.
But that is not the only style of coding that C++ can be used in. n As such C++ is technically a multiparadigm language of which OO is just one paradigm.
The term "C with classes" has a couple of meanings.
It is indeed object oriented but not strictly though.
Say for example, we can have just
which is nothing in the name of Object oriented and on the other hand we can have Classes, inheritance, polymorphism etc., that corresponds to Object Oriented.
It is up to us unleash the power of the language.
To the interviewer who asked you the question show a class a from C++ and ask him whether it is structured or procedured.. He will show you the same main() function I guess :)
So I guess it is based on what you have implemented that lies. But it has features that can make it to be considered as an OOP.
C++ is not an object-orientated language. The language is not any paradigm. This is in constrast to Java, which is religiously object orientated (no friend statement, for example). C++ offers object orientation, but isn't inherently object-orientated.