Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

GravtyKlz

advanced C or go on to C++

This topic is 5584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Going from C to C++ will introduce you to classes. Since you know structure, classes should be easy. Practice classes and inheritance.

Kuphryn

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
"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 ]

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!