advanced C or go on to C++

Started by
11 comments, last by GravtyKlz 21 years, 1 month ago
Ide say I have an intermediate understanding of C. I was just wondering if I should go on to an advanced level of C and then getinto C++, or do both, or just stop doing C now. I''ve seen some C++ code and ive read some primers on it so I know enough to know what people are doing in their code(for the most part). Im more fond of C but I''ve always programed in C and nothing else. Thanks.
Advertisement
Hey, great question, I''m wondering that too. I''m pretty good with complicated pointer notation but they aren''t second nature to me yet. I hope you get some good replies
Going from C to C++ will introduce you to classes. Since you know structure, classes should be easy. Practice classes and inheritance.

Kuphryn
Go to C++. Not because C isn''t a good (some would say great) language in itself, but because C isn''t a prerequisite to C++. If you want to learn C++, learn C++.

Having an understanding of C structs won''t really help you with classes (and remember that structs in C++ are classes), because C++ classes are about so much more than data aggregation. The principles of data hiding, abstraction, object-orientation, inheritance and ploymorphism have no C analogues, though you do say you are somewhat familiar with C++ so that should help.
I agree with Oluseyi. OO ist far more than just a new name - you will really implement a new concept of structuring your programs... And believe me: once you understand C++ and OO and you start to liek it, C will look very crude to you...

So, head on to C++!

------------------------------
"Reality is nothing, perception is everything!" - First Wizard Zeddicus Zu''l Zorander

------------------------------

There are only 10 kinds of people: those that understand binary and those that don't.

In that case tell me the best book on C++. Ide like to have something of good size that will cover things from the beginning and take it to an advanced level.
Personally I think The C++ Programming Language is one of the best.
Keys to success: Ability, ambition and opportunity.
"Essential C++" by S. Lippman
"Accelerated C++" by A. Koenig and B. Moo
"The C++ Programming Language" by B. Stroustrup
"The C++ Standard Library" by N. Josuttis

See also the book link in my signature.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote:
Original post by Oluseyi

The principles of data hiding, abstraction, object-orientation, inheritance and ploymorphism have no C analogues, though you do say you are somewhat familiar with C++ so that should help.


IMHO,

Data hiding works in C at module level. My habit is to make a module responsible for the creation and storage of the main data objects in that module, and pass to the outside world only a handle (an integer identifying the object), limiting the visibility to zero. I believe using handles is a case of abstraction, since I can call a single function for different object types. Inheritance can be simulated in C by replacing the "is" relation between class and subclass with "has". Polymorphism is directly supported through function pointers (in C you''d have to maintain a vtable by hand).
quote:
Original post by Oluseyi:
The principles of data hiding, abstraction, object-orientation, inheritance and ploymorphism have no C analogues, though you do say you are somewhat familiar with C++ so that should help.


Response by Diodor:
IMHO,

Data hiding works in C at module level. My habit is to make a module responsible for the creation and storage of the main data objects in that module, and pass to the outside world only a handle (an integer identifying the object), limiting the visibility to zero. I believe using handles is a case of abstraction, since I can call a single function for different object types. Inheritance can be simulated in C by replacing the "is" relation between class and subclass with "has". Polymorphism is directly supported through function pointers (in C you'd have to maintain a vtable by hand).

You can implement object-oriented design in virtually any imperative language (really, you can implement just about any paradigm in any other language, possibly with the exception of generics), often by resorting to coercing existing language features and being careful. The point remains, however, that C does not have intrinsic support for many OO features (methods must be implemented as member pointers-to-function; there is no possible mechanism to effect public, private or protected visibility; polymorphism in terms of base class pointers dispatching derived class methods requires a significant amount of work, void pointers, typecasting and a home-brew RTTI mechanism...). Of course it can be done - as mentioned before, cfront did basically this - but noone can argue against the statement that OO concepts and features are not a part of the C language paradigm.

[Edit: Confusing phrasing.]

[edited by - Oluseyi on March 7, 2003 6:15:59 AM]

This topic is closed to new replies.

Advertisement