-2

I had this doubt long time ago. The dot operator is first used in struct in C. Is the idea of Class or the design of Class based on struct in C? Actually I highly doubt it is, just haven't seen any official doco about this.

EDIT: What I am asking is if the idea of creating Class syntax (in C++) comes from struct in C, not why C is not an OOP language!

2 Answers2

3

No1.

While the syntax is vaguely similar, that's just syntax. The concepts of "classes" and "objects" predate C by several years2.

Simula was developed during the 60's:

Simula is a name for two simulation programming languages, Simula I and Simula 67, developed in the 1960s at the Norwegian Computing Center in Oslo ..

Simula 67 introduced objects, classes, inheritance and subclasses, virtual methods, coroutines, discrete event simulation, and features garbage collection. Subtyping was introduced in Simula derivatives.

Simula is considered the first object-oriented programming language. As its name implies, Simula was designed for doing simulations, and the needs of that domain provided the framework for many of the features of object-oriented languages today ..

The influence of Simula is often understated, and Simula-type objects are reimplemented in C++, Java and C#. The creator of C++, Bjarne Stroustrup, has acknowledged that Simula 67 was the greatest influence on him to develop C++ ..


1 Even though some concepts can be emulated in C, this does not imply that Object-Oriented Programming originated from, or is a result of, C structs or implementation.

2 Simula 67 was formally standardized in 1968, while the "the most creative period" in C development wasn't until 1972 when support for structs was added. The de-facto early standard for C ("The C Programming Language") wasn't published until 1978.

Community
  • 1
  • 1
user2864740
  • 60,010
  • 15
  • 145
  • 220
  • 1
    sure. to complete answer : C birth is 1972. even ancestor B was not earlier than 1969. – philippe lhardy Dec 22 '13 at 12:32
  • @philippelhardy Thanks. I added more refined dates to the answer. – user2864740 Dec 22 '13 at 17:37
  • 1
    ["C++ got the key notions of classes, derived classes, virtual functions (in other words, the notions of encapsulation, inheritance and polymorphism) from Simula just like Smalltalk did."](http://www.stroustrup.com/bs_faq.html#from-Smalltalk) – Casey Dec 22 '13 at 22:50
1

In early versions of C++ (or C with Classes), an object was directly implemented with struct. When you used cfront you could see it. Now it might be, but that's implementation dependent. As for the syntax, I believe it comes from algol (but I'm not certain).

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249