Programming with C++

I'm new to programming, and any tips examples, or projects would be helpful to not only me but other people interested

1 Like

There's a pretty cool book called [u]Beginning C++ Through Game Programming[/u]; generally speaking I find that learning a programming language is rewarding if you can see and interact with the results. That's pretty much how my school teaches it, I'd imagine that it'd be similarly effective if someone teaches him/herself that way.

cool, i'll take a look into it, thanks

learn the basics making sample programs... like make a logic statement, with some simple cin>> and cout<< stuff.... then make a function, and test that out.... then a structure, class, ext....


once you get done with polymorphism, you can go on one of two branches... gui / game programing, or platform API programing.... both meet up, and in the end you will learn both, but its about the order you learn stuff....


for example, if your running windows, and you learn windows sockets (internet stuff), then you will learn how to send data over the internet, and then later apply that to a game. if you go down the other path, you will learn how to make graphics, then you will learn other things such as network connectivity.


if you have any questions, pm me, talk to me on the irc, or email me at [email protected]

im not sure how advanced you are, but if your JUST starting out, i sugest using code::blocks for your IDE and minGW (gcc) for your compiler.... mingw comes with code blocks, and if you have any trouble setting it up, i can help you via chat, or remote support (such as team viewer)


EDIT: just some info about me, i taught my self basic c++ stuff (up to pointers and polymorphism in around 3 weeks, i then transferred into my high school's programing year 3 class... 1/2 way through the year. at the moment, i am programing a real time strategy game, and im learning winsock (i have a basic network class written, but its still work in progress). i went the game design path... lol anyway, yea... i can teach you dat c++

Download Visual Studio 2010 Express, It allows you to experiment with different programming languages in a fashion that has a familiar windows interface.


http://download.microsoft.com/download/1/E/5/1E5F1C0A-0D5B-426A-A603-1798B951DDAE/VS2010Express1.iso

Nate said:

Download Visual Studio 2010 Express, It allows you to experiment with different programming languages in a fashion that has a familiar windows interface.


http://download.microsoft.com/download/1/E/5/1E5F1C0A-0D5B-426A-A603-1798B951DDAE/VS2010Express1.iso

yes, but visual studios has a lot of bad things about it to. i dont like the general structure of the files... imo, they make everything buried too deep in menus. code blocks is heaven man :)

ztrain said:

yes, but visual studios has a lot of bad things about it to. i dont like the general structure of the files... imo, they make everything buried too deep in menus. code blocks is heaven man :)

Install Linux, familiarize yourself with VI or Emacs..

Deus Qain said:

Install Linux, familiarize yourself with VI or Emacs..

thats how we do it when starting out in c++ at chico state. vim, gcc, and gdb.

Question about the linux and the VI or Emacs. I'm a Java/C# student and we have to have a windows machine. Would there be any problems running it in a virtual machine?

Soap said:

Question about the linux and the VI or Emacs. I'm a Java/C# student and we have to have a windows machine. Would there be any problems running it in a virtual machine?

Works well enough for experimenting, etc.

Just do a dual-boot IMO. Windows/ a Linux distro.

Sounds like a good idea, i'll try that. Thanks

There's nothing wrong with virtualized machines also, take a look @ Virtual PC 2007.

using the book that littleviking posted (mines the 3rd edition) i'm having trouble with the game stat program, (its the 5th program you make) this is the error i get (i'm using MS visual C++ 2010 express btw)

------ Build started: Project: game_stats, Configuration: Debug Win32 ------

game_stats.cpp

c:\users\gigabuster.exe\documents\visual studio 2010\projects\game_stats\game_stats\game_stats.cpp(25): error C2065: '’y’' : undeclared identifier

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

when you choose which template, i always choose win32, it seemed to be the only one that worked, and has worked until now, the book didn't really tell which template to use

and i copy pasted directly from the pdf of the book so it should have the correct code unless there's a typo

try checking the variable y for a correct declaration


also i think for this book you probably want to just do an empty console application and not mess with that win32 junk.

Seems like you are trying to use an undeclared "y" variable. Make sure you have it declared in the "block" you are using it. It would be easier if you could post some of the code on here. Just put it between "quotes" boxes.


A common error I've seen would be something like that;

[quote]

import

int main()

{

int x = 10;


if (x == 10)

{

int y = 20;

}

std::cout << y;

}

[/quote]

Here, since you declared y within the if "block", it goes out of scope when you leave it, thus giving you an error.


This is just a common error I seem to see a lot...you might be way ahead of that though, don't be insulted if it's stuff you already fully understand!

Pop on the IRC if you need some help, ztrain's pretty solid with C++ and he's usually around till 11ish PM eastern. There's always someone who will probably be able to help you it if you need fast help.

[i]irc.wyldryde.org

razetheworld[/i]

no i'm at the beginning, and I'll try an empty console, thanks for your help

yeah when you make your project do win32 console application then when the win32 app window pops up click next then under additional options is a box that says "empty project" check that. you probably already know this but whatever.. actually i think that options under win32 console app and win32 project.. you just dont need the precompiled headers with what you are doing. this isnt related to your problem though just a side note.


but yeah as Pamplemousse said if you continue to have issues just post some code and someone will find the problem asap.

OR! Use Code::Blocks instead of Visual Studio.

Just create basic empty .cpp files, and write your code in that. You won't have any dependencies or anything as such. That's all you need really for basic console applications.

ok here's the code

// Game Stats

// Demonstrates declaring and initializing variables

include

using namespace std;

int main()

{

int score;

double distance;

char playAgain;

bool shieldsUp;

short lives, aliensKilled;

score = 0;

distance = 1200.76;

playAgain = ’y’;

shieldsUp = true;

lives = 3;

aliensKilled = 10;

double engineTemp = 6572.89;

cout << "\nscore: " << score << endl;

cout << "distance: " << distance << endl;

cout << "playAgain: " << playAgain << endl;

//skipping shieldsUp since you don’t generally print Boolean values

cout << "lives: " << lives << endl;

cout << "aliensKilled: "<< aliensKilled << endl;

cout << "engineTemp: " << engineTemp << endl;

int fuel;

cout << "\nHow much fuel? ";

cin >> fuel;

cout << "fuel: " << fuel << endl;

typedef unsigned short int ushort;

ushort bonus = 10;

cout << "\nbonus: " << bonus << endl;

return 0;

}