Is C++ an Object Oriented language?

2019-02-01 18:11发布

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?

标签: c++ oop
18条回答
小情绪 Triste *
2楼-- · 2019-02-01 18:53

Object-oriented programming (OOP) has become the preferrd programming approach by the software industries, as it offers a powerfull way to cope up with the cpmlexity of real world probleams. Among the OOP languages available today, c++ is far the most widely used language.

The languages should support several of the OOP concepts to claim that they are object oriented. depending on the fetures they support , they can be classified in to two categories.

  1. Object-Based programming languages.

  2. Object-Oriented programming languages.

    1. Object-Based programming languages. if it supports

         A. DATA ENCAPSULATION
         B. DATA HIDING AND ACCESS MECHANISAMS
         C. AUTOMATIC INITIALIZATION& CLEAR-UP OF OBJECTS
         D. OPERATOR OVER LOADING
      

      2.Object-Oriented programming languages.

      It supports all object-based programming features along with two additional features

        E. INHERITANCE
        F. DYNAMIC BINDING
      

hence Object-Oriented programming languages means

**Object-based features+ inheritance+ dynamic binding.**

Examples : C++, SMALLTALK,OBJECT PASCAL,JAVA

So , C++ is an OBJECT-ORIENTED PROGRAMMING LANGUAGE>

If you should still have some doubts in object oriented programming concepts refer the book of E.Balaguruswamy.

查看更多
爷的心禁止访问
3楼-- · 2019-02-01 18:58

C++ is an object oriented language. The problem is that some language zealots have their own, sometimes conflicting definition of OOP. For example, some Java people say that C++ is not an OOP language because you can define functions outside of a class.

Just ignore them.

查看更多
三岁会撩人
4楼-- · 2019-02-01 18:59

As other have said, C++ is not a PURE OO language. Then again, the only Pure OO language I know is smalltalk. The only pure functional language I know is the Lambda Calculus. I don't know ANY pure structured languages (They all have goto and/or multiple return statements)

Most people don't like writing in pure programming languages. It cramps their style.

查看更多
萌系小妹纸
5楼-- · 2019-02-01 19:00

The hallmarks of object-orientation are abstraction, encapsulation, polymorphism, and inheritance.

I'd say that C++ exhibits all four, so it qualifies as an object-oriented language.

It's possible write C++ as "a better C" and use a purely procedural style. Objects aren't mandated. Maybe that's what you're thinking.

查看更多
Melony?
6楼-- · 2019-02-01 19:01

The idea is that C++ is not just an object oriented language.

查看更多
Fickle 薄情
7楼-- · 2019-02-01 19:03

C++ is object oriented. c++ is c with classes is another way to say that c++ is c with oop added (and of course, there is more than that on top of c).

查看更多
登录 后发表回答