Clarifying a few things about c++
Posted: Thu Jan 14, 2010 9:36 am
Hey all.
I know I could probably find out all of this if I sat down and read a big book of learning c++, but I've always found that I barely learn from it. This is partly because I know enough from other languages that I tend to skip 90% of it, partly because it completely zaps my motivation to program in the first place, and finally because I usually do a good job of picking things up myself. These days I find I only really learn by going in head-first and doing something, rather then going through tutorials/books, etc. So - I HIGHLY appreciate everyone's time with this.
I've got some experience over a wide range of languages but for whatever-reason I've never been 100% sold on what I was using, mostly due to the lack of flexibility in said language. So for the up-teenth time I've tried c++ and finally after a round of c# and its namespaces I'm getting a semi-decent grasp of it. There's a few things about c++ that I've never dealt with before that I'm having difficult to understand (mostly conceptually). As such I'm making a small simple game kinda like missile command but a bit more..... modern - pretty much a 3D-rendered, 2D plane version of it, defending a planet, with enemies coming from all directions.
Well, to start, I know how to use a pointer, and what they do, but coming from a C#/AS background, I'm finding it difficult to know when to actually use them. I never seem to use them at all, really - all I seem to know is new classes should be pointed to? and so should constant strings? What's the effect of using a pointer over not? Faster? Less memory? When do I use them? Also, I know what a pointer is ( * ) (points to a memory location) and I know what ( & ) does (translates a memory location back to a value) but what is it called? (the &).
And what the hell is the deal with (const <stringtype> *) being shown everywhere for strings? I mean, how can you have a constant variable that you can remove? I assume that I'm reading it wrong, but rather it's saying that the variable's value is a constant............. which it isn't always is? What's the deal with const?
To start with I've made everything that should only appear/happen once as static as I'm used to writing this way, but I want to learn singletons and do it properly (also so I can use constructors/destructors properly instead of Init()/Shutdown()). I've looked a bit at how to do them them but I'm not really picking up on 'how to' do them.
What are some peoples favourite places on where to find winapi functions? The MSDN or is there some other perhaps easier/better places out there?
A question for ORGE users -
And finally (for now heh ) ascii/unicode. I haven't delved into unicode much, though I want to, it seems like orge is almost pure-ascii based? In my experiences it hasn't dealt well with unicode. I'd assume by now it'd fully support unicode where it is needed. I don't understand why we can't just work in a fully unicode orge/codeing enviroment. In my mind it'd make things so much simpler.
Finally, I've always had troubles trying to work out dynamic controls, the concept, pseudo-code, if you will. But that can wait for another topic when I've done a bit more work on this fantastical terrible engine of fail I'm working on. XD
Big thanks for everyone who takes the time to read and comment.
I know I could probably find out all of this if I sat down and read a big book of learning c++, but I've always found that I barely learn from it. This is partly because I know enough from other languages that I tend to skip 90% of it, partly because it completely zaps my motivation to program in the first place, and finally because I usually do a good job of picking things up myself. These days I find I only really learn by going in head-first and doing something, rather then going through tutorials/books, etc. So - I HIGHLY appreciate everyone's time with this.
I've got some experience over a wide range of languages but for whatever-reason I've never been 100% sold on what I was using, mostly due to the lack of flexibility in said language. So for the up-teenth time I've tried c++ and finally after a round of c# and its namespaces I'm getting a semi-decent grasp of it. There's a few things about c++ that I've never dealt with before that I'm having difficult to understand (mostly conceptually). As such I'm making a small simple game kinda like missile command but a bit more..... modern - pretty much a 3D-rendered, 2D plane version of it, defending a planet, with enemies coming from all directions.
Well, to start, I know how to use a pointer, and what they do, but coming from a C#/AS background, I'm finding it difficult to know when to actually use them. I never seem to use them at all, really - all I seem to know is new classes should be pointed to? and so should constant strings? What's the effect of using a pointer over not? Faster? Less memory? When do I use them? Also, I know what a pointer is ( * ) (points to a memory location) and I know what ( & ) does (translates a memory location back to a value) but what is it called? (the &).
And what the hell is the deal with (const <stringtype> *) being shown everywhere for strings? I mean, how can you have a constant variable that you can remove? I assume that I'm reading it wrong, but rather it's saying that the variable's value is a constant............. which it isn't always is? What's the deal with const?
To start with I've made everything that should only appear/happen once as static as I'm used to writing this way, but I want to learn singletons and do it properly (also so I can use constructors/destructors properly instead of Init()/Shutdown()). I've looked a bit at how to do them them but I'm not really picking up on 'how to' do them.
What are some peoples favourite places on where to find winapi functions? The MSDN or is there some other perhaps easier/better places out there?
A question for ORGE users -
And finally (for now heh ) ascii/unicode. I haven't delved into unicode much, though I want to, it seems like orge is almost pure-ascii based? In my experiences it hasn't dealt well with unicode. I'd assume by now it'd fully support unicode where it is needed. I don't understand why we can't just work in a fully unicode orge/codeing enviroment. In my mind it'd make things so much simpler.
Finally, I've always had troubles trying to work out dynamic controls, the concept, pseudo-code, if you will. But that can wait for another topic when I've done a bit more work on this fantastical terrible engine of fail I'm working on. XD
Big thanks for everyone who takes the time to read and comment.