Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Beginning with C++  (Read 15260 times)

0 Members and 1 Guest are viewing this topic.

Pedlya

Pederp
Beginning with C++
« on: July 17, 2006, 11:50:29 am »
  • Vote for Harvey!~
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2408
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.


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) )

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.
« Last Edit: February 27, 2010, 03:18:13 am by 4Sword »
Logged
So what! I wanna get out! 'Cos there's so much out there! So many different people, living different lives! Incredibly good guys, bad guys... Folks completely different from us! It's one huge melting pot! See, it's not about success, dying in the streets, who's better, who's not! I just want to be a part of it! I realized that even if I've no connections, no talent, even if I'm one big loser, I want to use my hands and feet to think and move, to shape my own life! We can just die here or we can try, see what we've got!

aab

^ Evolved from a Hobbit
Re: Beginning with C++
« Reply #1 on: July 17, 2006, 07:53:56 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 992
I was just this very day thinking about doing this too !

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




I ♥ Sol
.... I ♥ Sol ? wtf how long has that been there? >_> *rrrrrrrrar*
  • MySpace
Re: Beginning with C++
« Reply #2 on: July 17, 2006, 10:33:13 pm »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
May I add something to that?  Two books, Sams teach yourself C++ in 21 days and Game Programming all in one.
Logged



i love big weenies and i cannot lie
Re: Beginning with C++
« Reply #3 on: July 17, 2006, 11:38:09 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Sams teach yourself C++ in 21 days

You like that O_o, I bought that book skimmed through it and have never touched it since.
« Last Edit: July 18, 2006, 12:16:48 am by Helios »
Logged
Re: Beginning with C++
« Reply #4 on: July 18, 2006, 12:13:08 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
I bought alot of books, too many concentrated on Console apps. I made sure to get Console/Win32 ones from then on :/
Logged
the a o d c
Re: Beginning with C++
« Reply #5 on: July 18, 2006, 03:13:46 am »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
Yea, I actually do like it.  I always refer to that book when I need help before comming here or to hl2world
Logged



i love big weenies and i cannot lie

Raen

Are you retarded or something?
Re: Beginning with C++
« Reply #6 on: December 08, 2006, 12:57:56 am »
  • I'm the gosh-darn Batman!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 454
I'd like to give a bit of advice to those who wish to learn C++.

I myself am in the learning process, and I was talking to my dad the other day about what I was doing. He himself is a programmer, so he knows what he is talking about. He told me that learning C++ is good, but that as I learned, and need to be sure I was learning just as much about how to program as about C++. It's good to know a language, but learning how to program and how to think like a programmer is more important.

Languages change, and the industry standard changes. Right now C++ is dominant, but within 5 or so years, there will be a new language on top. But if you are a good programmer, then learning a new language is easy. But you have to be sure to learn about how to program, and not just memorize the languages.
« Last Edit: December 08, 2006, 03:43:12 am by Acid Rain »
Logged

www.myspace.com/applesofidunn

And yes, this is Acid Rain.
Re: Beginning with C++
« Reply #7 on: December 08, 2006, 01:12:17 am »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
yeah, that is a great point. I myself know quite a few different languages, and it's a WONDERFUL thing to be multilingual with programming, because things will change. A lot. Fast. This is the technology world, after all.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog

aab

^ Evolved from a Hobbit
Re: Beginning with C++
« Reply #8 on: December 12, 2006, 07:58:57 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 992
I'd like to give a bit of advice to those who wish to learn C++.

I myself am in the learning process, and I was talking to my dad the other day about what I was doing. He himself is a programmer, so he knows what he is talking about. He told me that learning C++ is good, but that as I learned, and need to be sure I was learning just as much about how to program as about C++. It's good to know a language, but learning how to program and how to think like a programmer is more important.

Languages change, and the industry standard changes. Right now C++ is dominant, but within 5 or so years, there will be a new language on top. But if you are a good programmer, then learning a new language is easy. But you have to be sure to learn about how to program, and not just memorize the languages.
Yeh, thats very important.
Thats pretty much how a proper university course is layed out.
In fact, they are making us write assembly programs this week, yet having not told us about it (im ok with the assembly, its dealing with the PIC microcontroller that's puzzling as they havent old us how the hell it does what it does, just to make it do things.. Hello, there are 65025 input possibilities and we have to somehow know on our own which ones do which things) ...Next year i've been told that they basically mention an obscure language and tell us to have programs finished for it in a week etc.
Fun!
Logged




I ♥ Sol
.... I ♥ Sol ? wtf how long has that been there? >_> *rrrrrrrrar*
  • MySpace
Re: Beginning with C++
« Reply #9 on: March 11, 2007, 09:45:51 pm »
  • odens knop
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1608
Is there a good guide to learn how to program?  Not some specific language, just basically how it's done to learn a thing or two?
Logged
|LEUS HERTAN MINAT|
Re: Beginning with C++
« Reply #10 on: March 11, 2007, 09:57:54 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Quote
Not some specific language, just basically how it's done to learn a thing or two?
That dosen't make a whole lot of sense, its sort of paradoxical - How can you program without a language?
Logged

Nuro

Re: Beginning with C++
« Reply #11 on: August 26, 2008, 12:19:25 am »
I've been looking forever for something like this. I played parallel towers and followed euclid's name to these forums in hopes of learning how to make my own heck.

Of course, i need to get better at C++ first. Ill be taking CS in college Sept 1. godspeed to myself <_>
Logged

Jeod

Team Dekunutz, Doubleteam
Re: Beginning with C++
« Reply #12 on: May 14, 2009, 07:20:57 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1675
I'm going to begin teaching myself C++ over the summer, and possibly posting what I learn here to make sure it's going smoothly. One of the last questions I have before downloading/researching all this stuff: is C++ the language to use for game programming, or should I be looking at something else? (C# or java, perhaps)
Logged
"You should challenge your fates. When all else fails, you can still die fighting." ~Yune
___________________________________

Zelda GBC+ Engine for Multimedia Fusion 2
  • Doubleteam Project Page
Re: Beginning with C++
« Reply #13 on: May 16, 2009, 03:44:48 am »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
I would personally stay away from Java for game development, mainly because the VM makes it slower.  C# and C++ are both fine for it, though (although you'll probably have an easier time with C#, but really it's a user preference if you ask me).  Just make sure you learn the language and understand it well (as well as programming concepts) before implementing directX or openGL or something.
Logged



i love big weenies and i cannot lie

Zer0XoL

Re: Beginning with C++
« Reply #14 on: April 20, 2010, 07:52:59 pm »
if noone dissagrees, could you add lazy foo´s SDL tutorials in the link list?  :D
its really good, and its perfect with OpenGL for input handling threads and all that stuff, also is multiplatform and can draw graphics by itself.
http://lazyfoo.net/SDL_tutorials/index.php

also these are some advice i have found usefull:
http://www.youtube.com/watch?v=zAgpsks29W4
 XD
Logged
Re: Beginning with C++
« Reply #15 on: June 13, 2015, 04:18:39 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 10
C++ primer is probably the best book for learning C++
Logged

Starforsaken101

Wake the Beast
Re: Beginning with C++
« Reply #16 on: June 13, 2015, 08:21:45 pm »
  • www.mouffers.com
  • *
  • Reputation: +69/-0
  • Offline Offline
  • Gender: Female
  • Posts: 2577
As much as your post was very helpful (I agree, the primer is great), this post dates back to 5 years ago. Please do not gravedig in the future!
Logged
  • Starforsaken101's DeviantART
Pages: [1]   Go Up

 


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



Page created in 0.048 seconds with 68 queries.