Originally posted by dee.
View Post
Announcement
Collapse
No announcement yet.
Ubuntu's Unity Written In Qt/QML For "Unity Next"
Collapse
X
-
Originally posted by Akka View PostWhich is the essential feature you don't have in C which prevent real OOP . Classes is only a name on a solution. What is the essential feature C lack?
You can read docs about classes
Comment
-
Originally posted by JS987 View PostI already said which features C is missing.
You can read docs about classes
http://en.wikipedia.org/wiki/Class_(...r_programming)
Similarly just because you're writing code using the "class" keyword doesn't mean you're writing an object oriented program. Many programs use "classes" as just modules to group related code not to create real objects.
Comment
-
Originally posted by admax88 View PostOOP has actually very little to do with the "class" keyword. That's just a convenience. You can build powerful object oriented systems in C using function pointers. To harness OOP you basically just need to be able to implement polymorphism, which you can do in C using function pointers. The syntax isn't as pretty but it works.
Similarly just because you're writing code using the "class" keyword doesn't mean you're writing an object oriented program. Many programs use "classes" as just modules to group related code not to create real objects.
C++ supports also functional programming. It's your decision if you use OOP or not.
Comment
-
Originally posted by JS987 View PostFunction pointer isn't same as method. You can't do real OOP without methods.
C++ supports also functional programming. It's your decision if you use OOP or not.
There's no reason you can't create functions and pass references (pointers) to them as parameters in C.
GObject is an object-oriented type system, written entirely in C. It's a C library. Then there's Vala, which is similar in syntax to C#, supports all the OOP features from C#, and it compiles to C + GObject code. You can try it yourself. Go on, write whatever small program with what you consider OOP, in Vala. Then compile it and look at the resulting C code. There's the same OOP code, but on a lower level, with all the abstractions showing as raw code.
Comment
-
Originally posted by JS987 View PostThey have equivalent.
Comment
-
Originally posted by dee. View PostA method is nothing but a function that gets passed an object reference, sometimes implicitly (as in C#, Java), sometimes explicitly (as in Python).
There's no reason you can't create functions and pass references (pointers) to them as parameters in C.
GObject is an object-oriented type system, written entirely in C. It's a C library. Then there's Vala, which is similar in syntax to C#, supports all the OOP features from C#, and it compiles to C + GObject code. You can try it yourself. Go on, write whatever small program with what you consider OOP, in Vala. Then compile it and look at the resulting C code. There's the same OOP code, but on a lower level, with all the abstractions showing as raw code.
In real OOP data are private and you have to use methods to access data. Direct access to private data in structure passed as reference isn't possible.
Vala compiler converts OO code to non-OO code. C code is never real OO code.
Comment
-
Originally posted by dee. View PostAnd no, no they haven't. Look up what prototype-based OOP is about. There's no classes, instead objects are made by cloning other objects (you create an object "prototype" that other objects are based on, hence the name). So no, classes are not necessary for OOP, they're just abstractions, a way of saying "this object creates other objects". Prototype-based OOP does away with the distinction between classes and objects, there's just objects that can make copies of themselves and those copies can be extended.
Comment
-
Originally posted by JS987 View PostC++ method is different from C function. Method is part of class namespace, but function is declared in global namespace.
In real OOP data are private and you have to use methods to access data. Direct access to private data in structure passed as reference isn't possible.
Vala compiler converts OO code to non-OO code. C code is never real OO code.
I do not now any practical easy way to get inheritance (I'm sure you can do it?) but I don't think that is a requirement for OOP. I'm sure most of the basic OOP patterns is older than the OOP languages.Last edited by Akka; 11 March 2013, 03:56 PM.
Comment
Comment