Resources > Coding

Beginning with C++

(1/4) > >>

Pedlya:
This is a topic to sticky so we dont have all the C++ topics.

Aab's post is the most informative so ill post that.


--- Quote ---I've stored things whenever ive made a rather large comment on C++ so i could avoid writing things again...So, here goes two of my stored posts:


In order of increasing level of useability (nothing too deep):

cprogramming.com   http://www.cprogramming.com/   //everyone knows this one, and should use it!..even though it didnt go past do loops when i was learning..Either that or i had real bad searching skills!
cplusplus.com   http://www.cplusplus.com/   //look at reference
cppreference.com   http://www.cppreference.com/index.html
Function And DataType Index   http://www.roguewave.com/support/docs/sourcepro/edition8/html/stdlibref/tindex.html
cpp-home.com   http://www.cpp-home.com/index/tiki-view_blog.php?blogId=1
function-x.com   http://www.functionx.com/cpp/
? page:   http://www.kegel.com/academy/tutorials.html
gamedev.net   http://www.gamedev.net/
Nehe   http://nehe.gamedev.net/
winprog.net   http://www.winprog.org/
Sgis table of STL contents   http://www.sgi.com/tech/stl/table_of_contents.html
C++ FAQ Lite   http://www.parashift.com/c++-faq-lite/index.html
OOPWeb.com   http://www.oopweb.com/CPP/Files/CPP.html //Look in particular at the STL guide
Optimisation article   http://www.tantalon.com/pete/cppopt/main.htm




A good thing to keep telling yourself is that theres nothing wrong with writing small programs that dont do too much, (or even anything) but get proressively larger or more complex.
Its obvious, yes. And alot of people want to skip that.
And when i say small programs, i mean small!

Hell, if i want to learn something new ill write a small driver for testing what ive learned: Small and withought any other purpose than to learn.
Having that attitude, that you are learning the language, not using it to produce things, should prevail in your head as you learn for a while. Eventually, some functionality in what your doing will become clear to you.

If you mean to learn C++ also, there are alot of ways of structuring larger programs that makes things much easier and more handlable. Your best off getting to grips with using and especially understanding why these things are important, through building progressively more complex programs, (also rewriting code to do things youll have previously done, only in a better way), as well as hanging about C++ forums and reading articles, tutorials, and specifications from time to time.

Heres a(n) (ordered) list of things to learn before doing anything lol, that i've given others: you may find it usefull ... Just dont be scared by it.

{
 ???  simple data types: beginning with int.
 ???  assignment operator, addition and subtraction, multiplication etc.
 ???  the (quite-obvious) semi-colon.
 ???  looking at more data types; char, unsigned int VS signed int, shorts, floats, doubles, (Mention word 'instance' here.) and then:
 ???  boolean values
 ???  initialising assingment
 ???  boolean operators
 ???  if
 ???  else
 ???  while
 ???  increment and decrement  operators
 ???  for
 ???  do while
 ???  arrays
 ???  references
 ???  const values
 ???  less intuitive operators, eg: binary and, or, xor, complement, mod, lsh, rsh
 ???  literals
 ???  order of expression evaluation
 ???  pointers
 ???  pointer iteration (through array)
 ???  calling functions
 ???  calling functions with parameters
 ???  dynamic allocation, ie 'new', and dynamic deallocation ie 'delete'.
 ???  Also, the C way of this: 'malloc' and 'free'
 ???  why iostream, not iostream.H lol.
 ???  std::cout
 ???  std::cin
 ???  functions
 ???  global variables, and thier pitfalls
 ???  enum
 ???  return
 ???  parameters
 ???  references as parameters
 ???  const, again, only with parameters this time.
 ???  implicit aggragates
 ???  multy dimensional arrays
 ???  namespaces
 ???  confined construction and deconstruction using braces '{' and '}'
 ???  use and using
 ???  std::ifstream
 ???  std::ofstream
 ???  C style string manipulation
 ???  std::string
 ???  std::stringstream
 ???  static keyword
 ???  prototyping functions
 ???  Proper organisation of files: .Hs being included in multiple C++ files that get linked together.
 ???  Understanding from a user-point of view what the compiler does
 ???  typedef
 ???  function overloading
 ???  inline
 ???  structs, C style
 ???  unions
 ???  some standard C library stuff, like rand(, time(), sin()
 ???  recap on pointers + '->' operator //important step: possibly the hardest is when you come to use this to delete an item in a linked list (next stage).
 ???  linked lists   //get past this and your into the world of unapplied
 ???  multi dimensional dynamic arrays, and why one should understand pointer syntax as early as possible in using these things: Make a big leap over a tall wall, and then you wont, like many, walk face into it, and think its all so confusing and hard and freakily random. Tip about pointer syntax: It all makes perfect semantic sense (with respect to a very discrete set of rules).
 ???  STL algorithms
 ???  implemeting your own common/usefull algorithms eg searching, sorting
 ???  STL objects: vector first, then lists, maps, sets, stacks etc
 ???  function pointers
 ???  typedef on function pointers
 ???  typedef on arrays
 ???  extern
 ???  template functions, and their compile time instantiation.
 ???  classes, private and public
 ???  methods
 ???  encapsulation
 ???  constructors
 ???  deconstructors (aka destrutors)
 ???  copy constructors
 ???  summary on object self-update and integrity
 ???  some examples of classes=>getting used to an abstract approach to the highest layer of a program.
 ???  implementing your own abstract containers for integers
 ???  overloaded operators
 ???  function pointers (being just objects) of function pointers=> arrays of functions
 ???  nested class.
 ???  inheritance
 ???  polymorphism
 ???  multiple inheritance
 ???  virtuals
 ???  pure virtuals, hence the Abstract Base class
 ???  static class members
 ???  implicit class fiddlings, and using the explicit keyword.
 ???  template classes.
 ???  int: special template argument.
 ???  default template arguments.
 ???  More class implementing: eg: make your own binary tree class, linked list class, dog class if you really wanted.
 ???  pointers to members
 ???  pointers to member methods
 ???  template specification
 ???  partial template specification
 ???  template metaprogramming.

}

Its important to practice using these techniques: Write programs using them as you learn.
Eg: once at one stage, write programs using the rest of he techniques together, if you can.
This may seem unusual as while going through the stages of learning the above, you can't really apply what you have learned into a visually interesting program.
Some (well ... everyone) write programs that do nothing but deal with console windows during earlier stages.
I wrote programs that done nothing other than demonstrate the technique that i had learned (experimanting and testing the limits of my knowledge of that technique), instead of writing programs dealing with expected input and output. But thats something you can decide for yourself.
Very -beyond- basic example:
Code:


#include<iostream>
int main()
{
   using std::cout;
   using std::cin;
   using std::endl;

   int x;

   cin >> x;
   
   cout << endl;

   if( x < 10 )
   {
      cout << "x is less than 10" << endl;
   }
   else
   {
      cout << "x is greater than or equal to 10" << endl;
   }

   cin.get();

   return 0;
}



I wouldnt recommend conciously learning things.
Its better to let it slip in through understanding and practice. That way, you cannot forget ...  e v e r !

Oh, and a basic tip so you never forget which order the '<<' and '>>' go with 'cin' and 'cout' (Dont know about you but i messed syntaxical things up alot at first in C++: It was very discouraging so i tried some BASIC for a while) :
   With cout << x; , x is being copied into cout, so it gets displayed on the screen, so the '<<' is pointing in the direction of 'cout'.
   With cin >> x; , a value in cin (an input value) is being copied from cin, into x, therefore the '>>' points in the direction of x, as though the value is moving into 'x'.
When learning the semantics behing syntax (What all the symbols mean), think carefully about why they mean what they mean, and why they are used like that.
Then, your brain wraps that concept youve learned into its own little nest in your mind, full of masses of details about core items which are therefore very easily detected when using your memory.


--- End quote ---

Also another occasion.


--- Quote ---Joining a forum like the c++learning community also helps, though i recommend not asking a question until youve exhausted 10-15 pages on google for multiple search terms, tried wikipedia, all of the links anyones ever given you, and before all that, tried very hard for yourself to solve the problem, and if your optimistic slept on it a night.
The more time you spend hammering into a problem and not telling people about it, the faster youll learn how to solve problems on your own, and that is afterall, programming ( though i personally hate the way many refer to everything as a 'problem'..It just doesnt sound right: First year computing scienece and high school chemistry alike ).
Also, as far as compilation errors go, the compilers often give good comments, as as long as you know, or can figure out the terminology (thinking about it, relating to your error to the response, then googling the terms and as a last resort asking for help).
The thing with programming, is that as long as you know everything to be known within your current context (ie inside the current file and further that function) your likely to not go wrong. And if you feel puzzled, you can list the things your trying to consider, and go through them, making sure they are ok (they i prefer to draw boxes and match lines inbetween them .. I know what i was like when i started and it basically involved the combination of the words 'flowcharts' and 'suck'. I use 'em as much as someone making a zelda fangame needs to plan their hyrule map out (which is a few times..i think) )
--- End quote ---

To get the Dev C++ program click here : http://www.bloodshed.net/dev/devcpp.html
A forum for you C++ needs is here : http://invisionfree.com/forums/CPPlearningcommunity/index.php?

Thankyou Aab so much for helping so many C++ noobs (like me) and being a cool guy about it.

aab:
I was just this very day thinking about doing this too !

Stickied (I dont see anyone disagreeing), and thank you Pedlya :D

MG-Zero:
May I add something to that?  Two books, Sams teach yourself C++ in 21 days and Game Programming all in one.

Infinitus:

--- Quote from: MasterGohan Zero on July 17, 2006, 10:33:13 pm ---Sams teach yourself C++ in 21 days

--- End quote ---

You like that O_o, I bought that book skimmed through it and have never touched it since.

AoDC:
I bought alot of books, too many concentrated on Console apps. I made sure to get Console/Win32 ones from then on :/

Navigation

[0] Message Index

[#] Next page


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Go to full version