Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

if c is object oriented then why does it not have classes like Java does...?

I'm learning programming and well- I always thought the reason we use classes is so that you know, you can create objects and instances of objects and all that but i don't get how if c/c++ is also object oriented then why doesn't it utilize the concept of classes? if c is object oriented without classes then why does Java need seperate classes?

5 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    "i don't get how if c/c++ is also object oriented then why doesn't it utilize the concept of classes? "

    C is not the same as C++.

    C is NOT object oriented; it uses a functional paradigm. There are no objects in C

    C++ is Object oriented and it does use classes and hence objects e.g.

    #include <iostream>

    #include <string>

    using namespace std;

    class person

    {

    public:

    string name;

    int age;

    };

    int main ()

    {

    person a, b;

    a.name = "Calvin";

    b.name = "Hobbes";

    a.age = 30;

    b.age = 20;

    cout << a.name << ": " << a.age << endl;

    cout << b.name << ": " << b.age << endl;

    return 0;

    }

    C does have structs, but this does not make it object oriented; it's more complicated than that.

    You may be thinking of object oriented C. This is C with classes but it is not the same as C++.

    "if c is object oriented without classes then why does Java need seperate classes?"

    C is not object oriented without classes.

    Java is also like c++ an object oriented language.

    C++ also uses a functional paradigm as well as an object oriented paradigm.

    If you like my answer plz give me credit :D

    Hope this helps

  • Anonymous
    5 years ago

    They may seem syntactically similar at first, but they're very, very, different. Wikipedia has a page comparing some of the basic syntax. Obviously, though, the biggest difference is Java's garbage collecting and pass-by-reference techniques, which take out a lot of the complexity in C++ code. Some people have said that the fact that the two languages look a bit similar is one of the hardest things to get over when you're going from Java to C++. What you need to understand is that two statements that look the same in C++ and Java can often actually mean totally different things.

  • 1 decade ago

    C is in fact not object oriented, but an imperative language, so it doesn't have classes. This is one of the differences between C and C++, perhaps one of the reasons why C++ is considered the upgraded version of C.

    C++ on the other hand is object oriented, and in fact does have classes, though you may opt not to use them as well, since C++ is backwards-compatible with C.

  • Anonymous
    1 decade ago

    Java needs four way associativity, but you can't have pointers, everything is locked out. C and C++ also is super locked out, but allows some throw back functionality. You can always have something of a class, like a struct or a list. By the time you have your data set up, there's no need for any confinement system. If you just make classes, they become bizzare 255 way associable because you access over hyratically, like really, sun and moon are in the same sky, not sun class, find moon class, then another helper class...

  • How do you think about the answers? You can sign in to vote the answer.
  • Anonymous
    4 years ago

    Does C Have Classes

Still have questions? Get your answers by asking now.