Archived

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

Ran into a wall with Liberty - please help.

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

It seems like most of the free world is able to learn C++ from the ground up from TY C++ in 21 Days, but I haven't had as much luck with it. After weeks of going over the first seven chapters and basically running away from the problem, I tackled Chapter 8 about a week ago... or rather, Chapter 8 tackled me. This was my third try with it. The chapter is about pointers and starts out with some fairly easy examples, but after two days of trying to make sense from the stuff in the middle of the chapter, I gave up and picked up a book by Heller, (Learning to Program in C++). After a few days of reading, I've learned more about what goes on under-the-hood when I'm programming. I'm even comfortable with some of the memory related terms and some of how Assembly language does what it does. I'm going to go over the first few hundred pages again before I go over classes. Once I've learned a topic, I have a feeling that the Liberty book will be more of a reference manual... like having taken decent notes in class. Before I move on, does anyone have any additional advice or encouragement? I'd like to eventually know C++, the Windows API, and Direct X (in that order). This seems like a long... long... way to go. I'm even considering grabbing a book about Assembly language before I move on to C++ classes, but I'm not sure what book about Assembly language would be relevant given my machine (I put together an XP 2100+ system a few months ago). Should I buy a C++ language reference or would that be no help at all given my current lowly stage of development? Also, this could be just me, but I find that copying code from a book is one of the most painful things in the world for me to do. On one hand, I want the experience of typing code for myself because it helps me to understand things. On the other hand, I get so dizzy looking from the book to the display and back that I want to puke. I also often get motion-sick with many 3D games (unless they have good frame rates and good view distance). I'm wondering if the two are related. Code from discs or web sites is nice, but I haven't found code that is typed AND explained on the same screen... usually one or the other. Anyway, any thoughts are appreciated. I'm really frustrated because I've buckled down and have been at this for weeks and can still only understand like 5 percent of what people talk about at GameDev. [edited by - Northchild on September 1, 2002 3:18:31 PM]

Share this post


Link to post
Share on other sites
Dont worry I went through about the same thing. How often do you practice coding using the features of c++ that you understand well? For me reading too much and not hacking apart the sample programs and not writing my own before moving ahead screwed me up. Once you get enough practice it should start to click in your head and you''ll begin thinking like a programmer. Pointers and functions and many other features of c++ are designed with neatness and structure in mind. To keep your data organised and clean. Dont even bother with assembly right now. Later on when you are writing programs that are speed critical you can learn assembly and optimise them but for now you have little use for it. The first book I bought to learn c++ I gave up on after about a month. Then I bought ivor hortons beginning visual c++ and quickly everything came together. Don''t give up, if you start going crazy get away from the puter and do something else and hit it again the next day. A fresh mind can do wonders. After I got a decent understanding of c++ I just read win32 tutorials on the net and now I''m playing with directx which also has many good tutorials around the web. It actually didn''t take that much work to get this far. You just have to keep at it. And yes copying code from a book onto the monitor can be annoying and hurt your eyes.

Share this post


Link to post
Share on other sites
I wouldn''t suggest anyone new in programming to learn C++ as the first language. Although there will always be some people who will get around with learning C++ first somehow, but still i dont think its a good idea. This however DOES''T mean that u should learn assembly as ur first language. I think learning C first would be a better idea. Now, there are some people who think C/C++ [ whatever ] is the toughest language on earth and one should learn something like PASCAL before even touching C/C++. THIS IS ONE HELL OF A BULLSHIT IDEA. If you want to learn C, just bang in it. Rather you will find C is lot easier than PASCAL when it comes to dealing with pointers, trust me. Once you get hold of C you can then jump to C++.... i guess that would be a smooth transition, and this will help you in many ways [ very difficult to explain in this small text box ]. Once you master C/C++ , try learning ASM although its not a must, but it will help a lot.

Share this post


Link to post
Share on other sites
Thanks for the words of wisdom! I''ve noticed that there are a ton of libraries that come with Visual C++ NET, are there any good guides about what these various library objects do? Do real software writers use things like the standard library?

Share this post


Link to post
Share on other sites
quote:
I wouldn't suggest anyone new in programming to learn C++ as the first language. Although there will always be some people who will get around with learning C++ first somehow, but still i dont think its a good idea. This however DOES'T mean that u should learn assembly as ur first language. I think learning C first would be a better idea. Now, there are some people who think C/C++ [ whatever ] is the toughest language on earth and one should learn something like PASCAL before even touching C/C++. THIS IS ONE HELL OF A BULLSHIT IDEA. If you want to learn C, just bang in it. Rather you will find C is lot easier than PASCAL when it comes to dealing with pointers, trust me. Once you get hold of C you can then jump to C++.... i guess that would be a smooth transition, and this will help you in many ways [ very difficult to explain in this small text box ]. Once you master C/C++ , try learning ASM although its not a must, but it will help a lot.


Why shouldn't anyone new in programming learn C++? Java is often taught as an introductory language, and it, like C++ is object oriented. Also, there are those who say that learning C first might be a mistake, especially if you're interested in learning object oriented concepts, as some people find it difficult to leave behind the procedural style of C vs. the OO C++.

[edited by - ares32585 on September 1, 2002 7:14:29 PM]

Share this post


Link to post
Share on other sites
I learned c++ as my first language, and up until the point where it introduced class''s I programmed like a C programmer. OOP is really a pretty simple concept it just takes some getting used to. So if you''ve gotten that far I can''t see why you''d suddenly become confused beyond help. It took me all of 2 minutes reading the introduction to class structure to get a basic understanding of how it works and for what reason. I will admit dealing with object''s was kinda weird at first. Took me a few minutes of deep thought wondering wtf.

Share this post


Link to post
Share on other sites
While I feel that I have a fairly good grasp of objects, I still don''t understand pointers as explained by Liberty. The infuriating thing is that I understand something like half of the chapter on pointers, but then it all falls apart somehow.

Share this post


Link to post
Share on other sites
i started reading the TY c++ in 21 days book but i never really finished it..i´m kind of comfortable with the first 9 chapters, then i just skipped some chapters and read some stuff here and there..then i got kind of sick of doing pure c++ so i started learning win32 and openGL, and i did so for a while. but then i felt i needed to learn c++ better, so i jumped back into my c++ book and read some more in it..

see, when i had done some opengl, i started to understand how to use pointers and stuff..maybe this is the way u should do it to..

Share this post


Link to post
Share on other sites
What dont you understand about pointers? Not sure what the point of them is? No pun intended. Pointers are just a tool that allows you to manipulate data in a more flexible way.

Share this post


Link to post
Share on other sites
Yes, I really don''t get the point.

I understand the part about accessing and writing variable values via pointers, but things start getting fuzzy on page 221, (paperback 4th ed), when I start seeing things like:

unsigned short int * pPointer = new unsigned short int;

Ok, he''s just declared an integer named pPointer that exists in the free store (due to the new unsigned short int assignment). This means that this (2 byte?) integer persists and is accessible beyond the function that it''s created within, (whereas auto variables don''t persist and static variables do persist but can''t be accessed?) This isn''t the same as a global variable, but I just don''t see how the end results are different. Wouldn''t everything have access to this pointer the same way that everything has access to a global variable? Do any of the little console programs in this book actually need pointers or will I see this once and then not again until I''ve advanced a couple of months?

The rest of the chapter is like wading through mud. I am taking some advice and going over basics again, writing small programs, etc. Hopefully I''ll get by this block. Thanks again.

Share this post


Link to post
Share on other sites
Okay, let me try and explain this. I take it the pointer to the free store variable was created in the function. One reason to do this is if you want to return a reference which contains the address of the dynamically created variable. I think you understand that part right? Where an auto variable created inside the function dies when the function exits. Another thing, the only way to allocate memory dynamically is with pointers. Okay, as for scope of a pointer, its just like any other variable, if you create a pointer to lets say int j = 5 inside the main function, then decide to call the blahblah(); function, unless u pass the pointer as an argument it wont be accesible inside blahblah, only main, pointers have regular scope. one reason why you might pass a pointer to a function would be for accessing array''s. Instead of passing the entire array which takes more time depending on the size of it, U can just pass a pointer to the first element or whatever in the array and then use a loop inside the function to access the rest. A static variable persists but is only accessible within its scope, just like an auto variable except that it doesn''t die when the function exits. So if you created a static variable inside a function that''s the only place you can access it. All in all pointers let you allocate memory dynamically and do stuff that you can''t with regular variables. Hope this didn''t just confuse u more.

Share this post


Link to post
Share on other sites
One more thing I forgot, another reason pointers are handy is lets say... You have an int variable j = 10 in your main function. You call a function blahblah(j); And you pass the VALUE 10, not the actual variable. So if inside the blahblah function you have

blahblah(int z)
{
z = 4; // this wont change the value of j out in the main function. But if you sent a pointer to j as an argument it would, if you changed the syntax of course.

blahblah(int * z)
*z = 4;

And you''re right, the use of pointers and what not are trivial in the dinky little example programs your book probably uses. But as your programs get bigger and you need to do things that are a bit tricky pointers will come in handy. And when you''re not sure how much memory you need to allocate at run time, new comes into play.

Share this post


Link to post
Share on other sites
Heh, I think we all get stuck in the same part! I''m on like chapter 9-11 which is references and pointers and right now I''m saying "Fuck it dude, this is for nerds." So I''m waiting for "Game programming all In One" from Amazon which covers basic c++ with complete game examples throughout the whole book. I think it''ll make learning c++ more interesting. I''ll dread going back to that cursed c++ in 24 hours...

Share this post


Link to post
Share on other sites