Jump to content

  • Log In with Google      Sign In   
  • Create Account

having a hard time learning C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
19 replies to this topic

#1 stein102   Members   -  Reputation: 485

Like
0Likes
Like

Posted 13 May 2013 - 06:51 PM

I come from a java background, and am honestly having the hardest time learning C++. I'm using the tutorial at learncpp.com and I find that I'm not retaining most of the information I've read. Everything seems so weird in C++ as opposed to java which I find to be very straight forward. C++ feels all jumbled and messed up, and I can't do a lot of the things I can do in Java (or haven't learned how to do it yet).

 

I feel like I have to invest a lot of time just to learn how to do something that should be really simple, such as inheritance (which I found really easy in Java).

 

I just want to get to the same level I was in Java, but this task is a lot more daunting than I originally assumed.

 

Any tips?



Sponsor:

#2 Khatharr   Crossbones+   -  Reputation: 3039

Like
5Likes
Like

Posted 13 May 2013 - 07:12 PM

Write more code.

 

When you complete a tutorial, instead of moving on to the next one, do a project using what you've learned so far. C++ is a more complex language to deal with than Java. That's one of the reasons Java was made. You'll do better with retention if you spend more time with hands-on learning. Just mess around with it and do silly things. Only move on when you feel comfortable with what you've got so far.


void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#3 Satharis   Members   -  Reputation: 1263

Like
5Likes
Like

Posted 13 May 2013 - 07:21 PM

My advice is just to keep coding.

 

Although doing projects inbetween is helpful, the biggest thing that helps you remember is time and repetition. Even doing the same tutorial 10 times over a few months will start to sink the syntax into your head.

 

Of course you shouldn't wait that long to code, just an example!

 

Once you get the basics down though, the best way to learn more advanced features is to do projects, when something comes up and you don't know how to do it, you'll look it up. Looking up a solution for a real problem is quite a bit more effective at sticking it in your head, whenever you see that same problem again you'll go, "I remember!"


Edited by Satharis, 13 May 2013 - 07:23 PM.


#4 georger.araujo   Members   -  Reputation: 824

Like
3Likes
Like

Posted 13 May 2013 - 08:59 PM

I come from a java background, and am honestly having the hardest time learning C++. I'm using the tutorial at learncpp.com and I find that I'm not retaining most of the information I've read. Everything seems so weird in C++ as opposed to java which I find to be very straight forward. C++ feels all jumbled and messed up, and I can't do a lot of the things I can do in Java (or haven't learned how to do it yet).

 

I feel like I have to invest a lot of time just to learn how to do something that should be really simple, such as inheritance (which I found really easy in Java).

 

I just want to get to the same level I was in Java, but this task is a lot more daunting than I originally assumed.

 

Any tips?

 

I recommend Bruce Eckel's free-to-download "Thinking in C++" books. Great content, good explanations - deep enough to clarify but not enough to lose focus - and good exercises. Sure, a bit old, but all code works (I ran most examples and solved most exercises with gcc and clang) and it won't stop you from learning C++11 after you've mastered the basics - actually, it will provide you with a solid base for C++11. Read Vol. 1 and do all exercises. Worth every second you spend on it.



#5 ISDCaptain01   Members   -  Reputation: 1443

Like
0Likes
Like

Posted 13 May 2013 - 11:29 PM

Check out thenewboston c++ tutorial on youtube. They are very clear for beginners

 

http://thenewboston.org/list.php?cat=16



#6 Limecore   Members   -  Reputation: 105

Like
0Likes
Like

Posted 14 May 2013 - 01:55 AM

I come from a java background, and am honestly having the hardest time learning C++. I'm using the tutorial at learncpp.com and I find that I'm not retaining most of the information I've read. Everything seems so weird in C++ as opposed to java which I find to be very straight forward. C++ feels all jumbled and messed up, and I can't do a lot of the things I can do in Java (or haven't learned how to do it yet).

 

I feel like I have to invest a lot of time just to learn how to do something that should be really simple, such as inheritance (which I found really easy in Java).

 

I just want to get to the same level I was in Java, but this task is a lot more daunting than I originally assumed.

 

Any tips?

 

I recommend Bruce Eckel's free-to-download "Thinking in C++" books. Great content, good explanations - deep enough to clarify but not enough to lose focus - and good exercises. Sure, a bit old, but all code works (I ran most examples and solved most exercises with gcc and clang) and it won't stop you from learning C++11 after you've mastered the basics - actually, it will provide you with a solid base for C++11. Read Vol. 1 and do all exercises. Worth every second you spend on it.

+1

I also came from a java background and  found it easy learning from that book

If you aren't already, use an ide like code::blocks. It will make your life easier



#7 NightCreature83   Crossbones+   -  Reputation: 3032

Like
2Likes
Like

Posted 14 May 2013 - 01:56 AM

Check out thenewboston c++ tutorial on youtube. They are very clear for beginners

 

http://thenewboston.org/list.php?cat=16

Please don't use this as your only source to learn C++ from as he leaves out information in his tutorials especially around the inheritance, virtual functions and polymorphism section.


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#8 Aliii   Members   -  Reputation: 1448

Like
0Likes
Like

Posted 14 May 2013 - 02:08 AM

Any tips?

 

Do projects instead of just coding aimlessly. That will work.

 

"C++ feels all jumbled and messed up"
 

Maybe it feels that way but its not:)



#9 jbadams   Senior Staff   -  Reputation: 19366

Like
0Likes
Like

Posted 14 May 2013 - 02:40 AM

Please don't use this [thenewboston] as your only source to learn C++ from as he leaves out information in his tutorials especially around the inheritance, virtual functions and polymorphism section.

He doesn't just leave out information, he's also outright incorrect at points.  A lot of beginners seem to find TheNewBoston's videos valuable and easy to follow, and so I've always taken the stance that I won't outright recommend not using them -- but you should definitely be using other resources as well to correct any mistakes and fill in the blanks.

 

 

Like the above, I would strongly recommend more practice -- things will stick with you once you're actually using them.  It can be frustrating moving from an easier language to something lower-level where you aren't able to do the same things as easily, but you'll get it if you persist. smile.png



#10 VladR   Members   -  Reputation: 722

Like
2Likes
Like

Posted 14 May 2013 - 07:53 AM

I'm surprised nobody mentioned The Famous C++ FAQ - http://www.parashift.com/c++-faq/

 

Over the years, I fond it to be an invaluable resource to refresh the knowledge (before an Interview) and connect all dots - with only a few lines/paragraphs of text (instead of 10 pages in some book).

 

Once you can answer all those questions, it will mean that you understand the design and implementation of the language, and you will be a master of C++  - of course, for that level of knowledge, you will need to go through many books - Design Patterns, STL, Template Metaprogramming, ...

 

I'm not sure I'd recommend Bruce Eckel's Thinking in C++ at this early stage, though. It's a pretty heavy read that is best to enjoy once you have a basic grasp on the most basic low-level C++ concepts like pointers, virtual methods and templates (and no, Java exp. doesn't really count here).

 

And that's before we even touch the subject of C++11....


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#11 NightCreature83   Crossbones+   -  Reputation: 3032

Like
0Likes
Like

Posted 14 May 2013 - 09:04 AM

I mostly used Cplusplus.com to learn C++ but I could already program at the time and was only interested in learning the syntax. Good thing about that site is it shows the way C++11 does things as well. I would start learning the basics of C++11 as well because "auto" (C# "var") and ranged for will make most of the crazy STL iterator stuff go away for you and it will seem more like C# or Java.

 

 

I'm surprised nobody mentioned The Famous C++ FAQ - http://www.parashift.com/c++-faq/

 

Over the years, I fond it to be an invaluable resource to refresh the knowledge (before an Interview) and connect all dots - with only a few lines/paragraphs of text (instead of 10 pages in some book).

 

Once you can answer all those questions, it will mean that you understand the design and implementation of the language, and you will be a master of C++  - of course, for that level of knowledge, you will need to go through many books - Design Patterns, STL, Template Metaprogramming, ...

 

I'm not sure I'd recommend Bruce Eckel's Thinking in C++ at this early stage, though. It's a pretty heavy read that is best to enjoy once you have a basic grasp on the most basic low-level C++ concepts like pointers, virtual methods and templates (and no, Java exp. doesn't really count here).

 

And that's before we even touch the subject of C++11....

 

As I mentioned before there are a few things in C++11 that make the langauge easier to use for people who are coming from higher abstraction layers, sadly not all the features are implemented in all compilers yet. GCC is currently mostly there and so is Clang I think. But the ranged for(foreach) and auto keywords are definitely something C# and Java programmer will understand and be able to harness.


Edited by NightCreature83, 14 May 2013 - 09:07 AM.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#12 VladR   Members   -  Reputation: 722

Like
0Likes
Like

Posted 14 May 2013 - 09:24 AM

Well, we've had the basic for_each for about a decade (perhaps slightly less) in C++, available from <algorithm>

That's probably an area I'd recommend anyone [coming from a managed language] to start.

 

I'm still not convinced C++11 makes things much easier for people coming from managed languages. Half of those concepts must seem pretty alien...

 

I still think one has to learn C++ bottom up - you do need to tear a bunch of hair here and there to truly appreciate things like Smart Pointers, STL data structures (over regular arrays), STL algorithms, ....

 

It's usually only then that the design choices of the language designers click


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#13 NightCreature83   Crossbones+   -  Reputation: 3032

Like
0Likes
Like

Posted 14 May 2013 - 09:49 AM

Most of the stuff in algorithm sadly require you to know about functors and function pointers to make them work effectively, using a lambda on those is actually a lot nicer then either of the previous one (see http://nwcpp.org/static/talks/2011/lambda.pdf).

 

But we are getting off topic here, the only way as mentioned before to really learn C++ is by shooting yourself in the foot repeatedly and learning from those mistakes, and C++ makes it easy to shoot yourself in the foot. So as a beginner I would stay away from anything that is intermediate level at the beginning and write code that just runs on the stack to begin with as you would in Java and C#. The heap is not hard to manage but object life time will come in to play when using the heap lots, as you need to manage the allocation on the heap as well as the deallocation of your objects in it.


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#14 Matt-D   Crossbones+   -  Reputation: 1469

Like
1Likes
Like

Posted 14 May 2013 - 11:37 AM

I'm using the tutorial ... and I find that I'm not retaining most of the information I've read.

 

I think that's your problem right there.

IMO, attempting to learn C++ using a tutorial is a 100%-sure recipe for confusion and failure.

Given that you're also going to have to un-learn what you've seen in most on-line tutorials on C++ (they usually follow egregiously bad coding practices), it's worse than a waste of time, it's a negative use of time.

 

Instead, I'd recommend you work through one of the books suggested here: http://isocpp.org/get-started

Note that "work through" is meant in the active sense -- in particular, as others mentioned, you must do the coding exercises, simply reading the book is not sufficient.

 

See also:

http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

 

More people in your situation (with relevant advice):

http://stackoverflow.com/questions/403431/switching-from-java-to-c-whats-the-easy-way

http://www.reddit.com/r/gamedev/comments/1b62qt/moving_from_c_to_c_having_already_knowledge_of_oo/

http://www.reddit.com/r/cpp/comments/zpigl/refreshing_c/
http://www.reddit.com/r/cpp/comments/ks4yd/learning_c_as_a_java_user_starting_with_the_snake/c2muazn
http://www.reddit.com/r/cpp/comments/hxc1f/can_anyone_suggest_a_good_book_to_help_with_the/
http://www.reddit.com/r/cpp/comments/12f3bl/which_book_is_best_to_learn_c/
 


Edited by Matt-D, 14 May 2013 - 11:44 AM.


#15 Álvaro   Crossbones+   -  Reputation: 13912

Like
0Likes
Like

Posted 14 May 2013 - 12:58 PM

I come from a java background, and am honestly having the hardest time learning C++. I'm using the tutorial at learncpp.com and I find that I'm not retaining most of the information I've read. Everything seems so weird in C++ as opposed to java which I find to be very straight forward. C++ feels all jumbled and messed up, and I can't do a lot of the things I can do in Java (or haven't learned how to do it yet).

What kinds of things can you not do?

I feel like I have to invest a lot of time just to learn how to do something that should be really simple, such as inheritance (which I found really easy in Java).

There is nothing simple about inheritance. But still, I don't think C++ makes it particularly hard.

I just want to get to the same level I was in Java, but this task is a lot more daunting than I originally assumed.

Any tips?

C++ is a confusing language. I failed to learn it on my own a couple of times. On my third attempt I was actually using it at work, where we have a local guru, and I succeeded. Don't get me wrong: After 11 years using C++ daily, there are still dark corners of the language that I don't understand, but I know to stay away from them. ;)

Anyway, as others have said, you need to do a lot of coding in C++ to get good at it. Feel free to post in these forums with more specific questions about difficulties you may encounter.

Edited by Álvaro, 14 May 2013 - 12:59 PM.


#16 VladR   Members   -  Reputation: 722

Like
0Likes
Like

Posted 14 May 2013 - 01:10 PM

The good thing about C++ [from the learning standpoint] is that it is incredibly unforgiving [especially compared to a managed runtime like C# / Java] and makes it very easy to mess things up.

 

Which is a good thing, since the long-term memory and coding reflexes are best initialized by spending hours in a debugger / stackoverflow / msdn and not by a single short exercise that works the first time you try it out.

 

 

As a kid, did you listen to your parents to not touch the Hot Iron on the Ironing board or did you rather learn by burning your hand smile.png  ?


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#17 tufflax   Members   -  Reputation: 499

Like
0Likes
Like

Posted 14 May 2013 - 05:27 PM

I'm surprised nobody mentioned The Famous C++ FAQ - http://www.parashift.com/c++-faq/

 

Over the years, I fond it to be an invaluable resource to refresh the knowledge (before an Interview) and connect all dots - with only a few lines/paragraphs of text (instead of 10 pages in some book).

 

Once you can answer all those questions, it will mean that you understand the design and implementation of the language, and you will be a master of C++  - of course, for that level of knowledge, you will need to go through many books - Design Patterns, STL, Template Metaprogramming, ...

 

I'm not sure I'd recommend Bruce Eckel's Thinking in C++ at this early stage, though. It's a pretty heavy read that is best to enjoy once you have a basic grasp on the most basic low-level C++ concepts like pointers, virtual methods and templates (and no, Java exp. doesn't really count here).

 

And that's before we even touch the subject of C++11....

http://yosefk.com/c++fqa/

 

My tip: Leave C++ and never look back. It's pure evil.



#18 LorenzoGatti   Crossbones+   -  Reputation: 2763

Like
1Likes
Like

Posted 15 May 2013 - 01:52 AM

&nbsp;

I recommend Bruce Eckel's free-to-download "Thinking in C++" books. Great content, good explanations - deep enough to clarify but not enough to lose focus - and good exercises. Sure, a bit old, but all code works (I ran most examples and solved most exercises with gcc and clang) and it won't stop you from learning C++11 after you've mastered the basics - actually, it will provide you with a solid base for C++11. Read Vol. 1 and do all exercises. Worth every second you spend on it.

&nbsp;

It WAS a good book, but C++ has progressed and now it is a good book about an obsolete language that shouldn't be used. There are, of course, common roots, but why learn (and unlearn) old and unpleasant techniques along with the complex enough current state of C++?

A random example of how modern C++ has removed syntactic and conceptual cruft:
http://herbsutter.com/2013/05/09/gotw-1-solution/
Produci, consuma, crepa

#19 JiiPee   Members   -  Reputation: 135

Like
0Likes
Like

Posted 15 May 2013 - 06:08 AM

I think C++ is a great language. You can do so many neat memory management tricks with C++ than with Java or .NET. It is also a true work horse if you get your code right. For me, understanding how memory layout and memory management works in C++, helped a lot learning C++ language. I think it is also quite cool that when you work with C++ you'll get to know how memory management works in OS and you surely get know difference between stack and heap memory and what are pros and cons per each.

 

When you learn all these, moving then to some more higher level language is quite easy. It is good to know, that even if you are using Java or .NET same C/C++ things happens under the hood. I think it is kind of language what gives to you quite a lot of. It takes time to learn, but I think it's totally worth of.

 

Altough I hate header file comments when working with std-library. It's so cryptic, I'll have to say that. Fortunately in cplusplus.com std-library is documented quite well.

 

This is not perhaps best example, but I found it really cool that how easy it is to corrupt stack with C standard methods and run method from the stack with buffer overflow attack. That kind of things just open your eyes. It was a practice what we did in school.


See my game dev blog: http://gamedev4hobby.blogspot.fi/

#20 Serapth   Crossbones+   -  Reputation: 5751

Like
0Likes
Like

Posted 15 May 2013 - 09:46 AM

Actually C++ is an abstraction over the memory management system of the OS, which itself is an abstraction over the actual hardware. That's the first time I've heard the fragility and insecurity of C++ as a plus point!


To the OP, if you got the language basics down, try the tutorial in my sig. It covers a lot of C++ concepts, but with real non trivial code.

This is why I hate most book samples, it's hard to grok something when all the examples are so abstract.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS