simple recursive statement, or is it? Can't grasp it

I'm using the jumping into c++ book by alex allain to learn c++ programming and I'm at recursive functions. First example shown and I'm lost.... So simple I can't help but feel this can't possibly print what he's saying it does... (probably wrong)
1
2
3
4
5
6
7
8
9
10
void printnum ( int begin )
{
  cout<< begin;
  if ( begin < 9 )         // The base case is when begin is greater than 9
  {                           //  for it will not recurse after the if-statement
      printnum ( begin + 1 ); 
  }
  cout<< begin;         // Outputs the second begin, after the program has
                              //  gone through and output
}


is supposed to print 1234567898987654321 but I can't begin to see how that even would work... normally he's incredibly concise with his descriptions but he's losing me hard so far this chapter. could you please explain how this works, specifically after it reaches 9. thanks an lot
jumping into c++ book by alex allain
is hard enough for any beginners. its not a useful book even for intermediate or experts!
just go to
learncpp.com
and see how easy is C++.
a composed pdf version of the tutorials is freely available from:
https://drive.google.com/file/d/0B24Ki1Y3V2tzdlBqNEVkRllmMU0/view?usp=sharing
learncpp is outdated though.

Here is how printnum works:
print input
if input < 9, call function with input + 1. Everything it prints gest outputted to screen here
print input again.
So if you call it with 8, here is what happens:
print 8
{call function again with 9}:
    print 9
    {no call as 9 not less than 9}
    print 9
    {end recursive call}
print 8
{original function ends}
If you call with 1, it will work like that:
1
|-2
| |-3
| | |-4
| | | |-5
| | | | |-6
| | | | | |-7
| | | | | | |-8
| | | | | | | |-9
| | | | | | | |-9
| | | | | | |-8
| | | | | |-7
| | | | |-6
| | | |-5
| | |-4
| |-3
|-2
1


learncpp is outdated though.
7 years can make "outdated" to an expert. but not to a beginner, those basic things aren't likely to change soon. so, whats new in C++11 & 14 for a beginner? not so many things. one Wikipedia page is enough to know.

the tutorials were constructed mostly in 2007 and 2008. it has a chapter of C++11 features at the end. the tutorials are still valid. it didn't use outdated headers like <iostream.h>
the examples compiles fine in recent compilers.
its the easiest path for the beginners as far as I've seen. it explains everything very clearly.
cplusplus.com tutorials have less explanation - are very compact. it need to be more elaborated, such as, how would you use a fstream object to both read and write in a single file. learncpp shows a lot of useful things like this.
Thanks for the help guys. I really have found my book useful as he gets into some detailed explanations! It was when I started reading a book on opengl that I understood the term learning curve. Yikes.

Moving on though. It seems most resources skip teaching about the latter half and the recusive function call stacks as if people are expected to think it's some behind the scenes magic!!

Anyway, heres a beautiful explanation for those interested:
http://m.youtube.com/watch?v=k0bb7UYy0pY


whats new in C++11 & 14 for a beginner?
Automatic type dedution, range iteration, move semantic, smart pointers, lambdas, uniform initialization, constructor delegation, library extension and more.

The problem is, C++11 changed best practices and outdated some widely used C++11 practices. Some of widely used C++03 features is now a bad practice and does not work well with C++11 features. Namely NULL and perfect forwarding which is very often used. Future deprecation (and unofficial deprecation now)

It is still mostly fine except for some chapters/paragraphs, but it teaches old habits which should be avoided. Main problem with it that it is goes "Learn this, and now relearn again" approach instead of fixing existing tutorials and making additional chapter for those who do not want to reread again.
everyone has his own "up to date" definition. what do you think when you see beginners asking for help using <iostream.h> , smile ?
Topic archived. No new replies allowed.