Skip to main content
GameDev.net gamedev.net
🔒 Locked

C?

Started by EvilCrap Dec 6, 2001 at 4:58 PM 27 replies 600+ views
Original Post
EvilCrap
EvilCrap
i need to take a test on C, but have only studied C++, i was wondering if my understanding of the differences is accurate: C does not support: function/operator overloading, classes, on-the-fly declarations, const, bool, streams, new/ delete, C does support: variable/function scope, byref/byval, structs, function pointers, struct inheritance, int, long, float, char, double, sizeof(), ++/ =+ (and variations of), Shifts (<<), declaration initialization (int x = 0, what else am i missing? thanks for help!
Russell
Russell
Templates is one I can think of. Maybe some other small things like virtual functions, inheritance, contstructors, destructors (all of those fall under your class category that you mentioned though), the difference between C comments (/* comment */)and C++ comments (// comment). You don''t have to add .h when you include header files in C++ (or at least you''re not supposed to have to according to the C++ standard). Namespaces are another that come to mind. That''s all I can think of, but I''m sure I''m probably missing something.
jacksonh
jacksonh
C supports const, but not const variables. So you can use it for arguements strcmp( const char *, const char *);
jacksonh
jacksonh
hmmm, thanks I allways thought it didn''t support const variables. Guess I should check these things before I answer a question.
BASSOFeeSH
BASSOFeeSH
quote:
Original post by Anonymous Poster
C doesn''t support ++. I''m not sure about += though.


Um....are you sure about that!!!????



Wait, wait, wait....who''s Nambla Fett?
-- What would Sweetness do?
BASSOFeeSH
BASSOFeeSH
The name ''C++'' is a pun...you know...''C'' incremented.

Wait, wait, wait....who''s Nambla Fett?
-- What would Sweetness do?
Oluseyi
Oluseyi
quote:
...the difference between C comments (/* comment */)and C++ comments (// comment).

There is none. C and C++ both (now) supoort /**/ and // style comments.

As of C99, I believe C supports bool and on-the-fly declarations, and has always supported function overloading.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
TerranFury
TerranFury
You can allocate an array of X elements where X is a constant in C++:

  
const int LEN=182;
char myString[LEN];


But you can''t in C. You need to use an actual number (or of course a #define). This may have been changed in the latest revision though.
TerranFury
TerranFury
Also, the syntax for creating struct types is different. C syntax (typedef struct{}name;}works in C++, but C++ syntax (struct name{...} doesn''t work in C.
BaShildy
BaShildy
Oluseyi: after reading your comments about C99 and I did some research. It was interesting to know all the new things C supported that i didn''t know about. I couldn''t however find a list of what the visual C compiler supports of these features. I did find a GCC C99 compliance list and it seemed the GCC compiler has gotten a small amount of C99 working, but is still in the process of adding the new features. Do you know offhand if Visual Studio 7 will have C99 compliance?

Code comment of the week:
bool hack = false; // DO NOT CHANGE THIS EVER
Kevin "BaShildy" KingGame Programmer: DigiPenwww.mpogd.com
EvilCrap
EvilCrap
thanks guys!! (...)
where is there a site with all this c99, etc documentation?
Oluseyi
Oluseyi
quote:
Original post by BaShildy
Do you know offhand if Visual Studio 7 will have C99 compliance?

I seriously doubt it; Microsoft has made it clear that "standards compliance" is less of a priority for them than ensuring backwards compatibility for all their clients and making sure major libraries (boost, STL for C++, etc) can be compiled without (excessive) change. However, they usually implement standards-compliant behavior as an option.

I would venture that VS.NET wont be C99-compliant out of the box, but after a few service packs (heh) it will. I believe the Microsoft C compiler already supports features such as bool, though...

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
eagleboy
eagleboy
c++ is a superset of c.
Oluseyi
Oluseyi
quote:
C was designed as an procedural programming language.
C++ was designed as an object oriented programming language,

Not really. These are labels that we''ve tacked on to these languages now, but if you read K & R (or look up the origins of C as well as C++) you''ll find that C was written for the purpose of writing operating systems. The very first large-scale project to utilize C was UNIX (ca. 90% C, <10% asm) which is why the two are inextricably linked. C++ evolved out of C (it was originally called "C with classes") to support the "new" (relatively) object-oriented programming paradigm. It is just as possible to write object-oriented code in C as it is in C++; it''s just a little harder.

Interestingly, I''ve heard and read it said that C++ isn''t "true" OO anyway. Whatever, it''s a convenient tool that suits my needs

quote:
About the struct thing as far as I know:

As stated in certain earlier posts, C now supports the same structure declaration/construction syntax as C++.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
Fruny
Fruny
quote:
Original post by Oluseyi
The very first large-scale project to utilize C was UNIX (ca. 90% C, <10% asm) which is why the two are inextricably linked.



I''ve seen it termed as ''C was written "in" UNIX and then kindly returned the favor''.

"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
Null and Void
Null and Void
quote:
Original post by Anonymous Poster
First of all
C was designed as an procedural programming language.
C++ was designed as an object oriented programming language, but of course through the compatibility of C++ to C you can also do traditional procedural programming in C++ or mix both styles.


Technically making C++ a multiparadigm language, not merely an object oriented one. One of the main reasons I''ve always liked both C and C++ is that they don''t force you to do anything one way; C++ is simply a continuation of this freedom.

[Resist Windows XP''s Invasive Production Activation Technology!]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.