Jump to content
  • Advertisement
Sign in to follow this  
Garett

Relearning c++

This topic is 4956 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

Ok, so a couple of years ago I kinda got into c++. I didn't get really far, but now i want to get into development as a career. I've been using 3d studio max a lot and I love doing it. so naturally gaming is my area of interest. ummm but there are a few things I don't get when I came back to coding. what's with this cin.get() and cin.ignore() stuff? the tutorial explained it but I just don't follow. Another thing is the using namepsace std;. I don't really know what this is for either. can anyone help me?

Share this post


Link to post
Share on other sites
Advertisement
cin.get() gets input and cin.ignore() ignores input

a namespace is a collection of things. It holds classes, functions, variables and the such. To use the namespace globally you declare using namespace std.

If you don't wanna use it globally just do std::cin, std::cout , or whatever

Share this post


Link to post
Share on other sites
Sounds like you'd be better off learning C.

With C, your learning more towards the fundamentals of your computer: memory (memset, memcpy).

With C++, your learning more towards abstract concepts of programming: polymorphic object orianted programming: inheritiance, overloading.

I'll leave it at that, since I'd like to keep my rating > 0. [razz]

Need inspiration? I'll let you know, I'm currently writing a MMORPG in C, and its turning out very very nicely. I got a complete UDP Winsock implementation coded in under 30 lines, that includes the ability to chat/walk/fight. In addition, my server code is almost finished, being just under 1000 lines, and it handles everything: accounts, banishments, game physics, using only the most basic functions, and only a single structure.

Even better, my website is hooked up with CGI, so webusers can create their accounts on my website, than push a button, and my internet server will run one of my C programs that will create their account with the given information off their browser (I love CGI!).

My point: Don't let the simplicity of C get you concerned. C can make very tight and high performance programs: since it's alot closer to assembly than C++ is.

Though, on a side note, DirectX is object orianted. If you try using C, you'll have to change your code a little. Prolly be better to use OpenGL (Procedural), since it's even portable.

Edit: I forgot the most important part, C is easier to learn than C++!

Share this post


Link to post
Share on other sites
OOP would prolly be easier if they learned it off the back. Going Procedural to OOP sucks. Its better if they are familiar with OOP and then making big programs.

Share this post


Link to post
Share on other sites
Quote:
Original post by SumDude
OOP would prolly be easier if they learned it off the back. Going Procedural to OOP sucks. Its better if they are familiar with OOP and then making big programs.


I strongly disagree on that one. My reasons are as follows...

1) He might give up, if it takes him a year before he can make anything interesting.
-Learning C++ from scratch is like... 20 lessons.
-Learning C from scratch is like 5 lessons.
[Reference: www.about.com (C/C++ Tutorials)]

2) C++ and C share some similiarites.
- C++ is an expansion to C.
- C structures behave just like C++ classes.
- With a few function pointers, you can make C++ classes out of C's structures. [razz]

Share this post


Link to post
Share on other sites
Thanks for your help :)

I'm going with c++ because I bought a game coding book that requires c++ knowledge.

I think I've made a mistake though. I got to a part in my c++ tutorial.

http://www.cprogramming.com/tutorial/lesson7.html

Is this C or C++?

Share this post


Link to post
Share on other sites
its C++, in C variables that are stucts must be declared using the struct key-word.

C++:

struct Tag {
Members
};

Tag something;


C:

typedef struct {
Members
} Tag_t;

Tag_t something;


C (again):

struct Tag {
Members
};

struct Tag something;

Share this post


Link to post
Share on other sites
Quote:
Original post by Westeria
-Learning C++ from scratch is like... 20 lessons.
-Learning C from scratch is like 5 lessons.
you can learn neither language in just X lessons :) im still learning new things 7 years after i started C++
Quote:
Original post by Westeria
- C++ and C share some similiarites.
- C++ is an expansion to C.
true, but they have just as many dissimilarities.
Quote:
Original post by Westeria
- C structures behave just like C++ classes.
- With a few function pointers, you can make C++ classes out of C's structures.
using member function pointers is quite frankly a sad hack, if you're going to all that trouble, why not just use C++ and get the "free" polymorphism and templates?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I ordered Teach yourself c++ in 24 hours 3rd edition. I liked the second edition so I thought this one would be good too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!