Page 1 of 3

Re: My C++ adventures!

Posted: Mon Aug 25, 2008 5:40 pm
by That

Code: Select all

#include <iostream>
using namespace std;

int b( int a )
{
  return a * a;
}

int main( int argc, char** argv )
{
  cout << b( 10 );
}

Re: My C++ adventures!

Posted: Mon Aug 25, 2008 7:37 pm
by That
Responding to your question about setting up SDL,

  1. Download the SDL development package (currently SDL-devel-1.2.13-VC8.zip) from the SDL site.
  2. In the package, copy everything in /include/ to C:\Program Files\Microsoft Visual Studio 8\VC\include\.
  3. In the package, copy everything in /lib/ to C:\Program Files\Microsoft Visual Studio 8\VC\lib\.
  4. In the package, copy /lib/sdl.dll to C:\Windows\System32\.

Then, to actually use SDL in VS,

  1. Make a new Project. It must be of type Win32 Console Application.
  2. In Application Settings (the second screen of the New Project Wizard) uncheck Precompiled Header.
  3. Delete all of the pre-made files. They are useless.
  4. Go to Project -> Properties.
    1. In Linker -> Input, put opengl32.lib glu32.lib sdl.lib sdlmain.lib as the value for Additional Dependencies.
    2. Optionally, go to Linker -> System and set the Subsystem to Windows (/SUBSYSTEM:WINDOWS). This will stop the Console window from being shown when the application is run; I suggest leaving it displayed whilst you're debugging, and then disabling it for final release.
  5. You can add .cpp and .h files to your project by right clicking the project name in the Solution Explorer sidebar, and then going to Add -> New Item and selecting either .cpp file or .h file.

These instructions are for VS2005 but I'm sure they'll adapt to VS2008 fine.

Re: My C++ adventures!

Posted: Tue Aug 26, 2008 10:34 am
by i.mosfet
"Hello World" wouldn't be too much ask Karl...

Re: My C++ adventures!

Posted: Thu Aug 28, 2008 1:58 am
by i.mosfet
My Human Gets Me Blues wrote:I can't use classes, therefore they are gooseberry fool. Discuss!

(Note to self: read this later.)



Good to see that you are getting there. The great thing about OOP is that once you learn how the whole things hangs together, then it's not too hard to turn your hand to all sorts of other programming languages.

Re: My C++ adventures!

Posted: Fri Aug 29, 2008 2:19 pm
by TS2Master
Yay! One more programmer in the world is a good thing. Keep it up and in a few years you'll be making games!

Sometimes I wish there was a perfect situation that was extremely simple that would model classes simply for young starters, without being a completely made up and arbitrary problem that doesn't really need a class. Know what I mean?

Re: My C++ adventures!

Posted: Fri Aug 29, 2008 8:54 pm
by ~Earl Grey~
Karlprof wrote:

Code: Select all

#include <iostream>
using namespace std;

int b( int a )
{
  return a * a;
}

int main( int argc, char** argv )
{
  cout << b( 10 );
}


Good one! I'm quite a fastidious coder. I prefer "x (y)" to "x( y )" myself though. :)

At least he didn't use void main ().

Re: My C++ adventures!

Posted: Fri Aug 29, 2008 8:59 pm
by ~Earl Grey~
My Human Gets Me Blues wrote:I can't use classes, therefore they are ****. Discuss!

(Note to self: read this later.)


Have you used structs at all yet, then?

Classes make things so much easier, too. You can put functions in structs, but the general convention is to use them for variables only.

I must admit, I have a very idiosyncratic coding style that's a hybrid between C and C++. I use classes and the new and delete operators, but I still pass-by-reference the C way (using a pointer) and don't bother with namespaces, templates and I've never dabbled with exception handling yet. I also still include header files using the .h extension.

Re: My C++ adventures!

Posted: Fri Aug 29, 2008 9:03 pm
by ~Earl Grey~
My Human Gets Me Blues wrote:
~Earl Grey~ wrote:I prefer "x (y)" to "x( y )" myself though. :)


Oh my god Karlprat is going to bite your ass off now.

In his defence though I've changed my habits and have already got used to x( y ) and it does indeed improve readability.


I don't like it. It looks ugly to me. I also hate it when people don't put the opening brace on the next line.

Re: My C++ adventures!

Posted: Wed Sep 03, 2008 3:30 am
by ~Earl Grey~
Arghh!

Pointers to class member functions make my head hurt! After figuring out the clunky syntax I find you can't even use them in a derived class (where the pointer was declared in the base class) to point to a derived class member.

Re: My C++ adventures!

Posted: Wed Sep 03, 2008 11:32 am
by Dolph Wiggler
I'm pretty well versed in Java but i was thinking of learning C++ during my spare time this year. Is it a lot harder than Java and will a lot of my Java knowledge cross over?

Re: My C++ adventures!

Posted: Wed Sep 03, 2008 5:43 pm
by ~Earl Grey~
Java's syntax is essentially borrowed from C++, but there are obviously differences. Function calls, if/else blocks and loops are prety much identical as far as I recall (which isn't to be taken for gospel).

I did some Java at uni and already knowing C++ definitely made it easier.

You might want to read-up on pointers though.

Re: My C++ adventures!

Posted: Fri Sep 05, 2008 9:25 pm
by Johnny Ryall
I don't know what this is.

Re: My C++ adventures!

Posted: Mon Sep 08, 2008 4:37 am
by Oblomov Boblomov
Lol geeks.

Re: My C++ adventures!

Posted: Wed Sep 10, 2008 8:29 pm
by Lex-Man
Freak Out Requiem IV wrote:I can't use classes, therefore they are ****. Discuss!

(Note to self: read this later.)


I can therefore they rule!!!

Re: My C++ adventures!

Posted: Wed Sep 10, 2008 8:30 pm
by Lex-Man
Have you thought about starting with an easier language?

If you learn Java first for example, its easier to jump into C++ from a more knowable place.

Re: My C++ adventures!

Posted: Sun Sep 14, 2008 7:48 pm
by ~Earl Grey~
Image

Image

Coming soon...

Re: My C++ adventures!

Posted: Thu Sep 18, 2008 9:44 pm
by ~Earl Grey~
Here's a cool little program I wrote.

Re: My C++ adventures!

Posted: Fri Sep 19, 2008 3:32 pm
by ~Earl Grey~
Yeah I did that in the Tonkinfrash days. Still a cool little util though.

The Darkplace game is coming on, too.

Re: My C++ adventures!

Posted: Fri Sep 19, 2008 6:38 pm
by ~Earl Grey~
No, I posted 2 images and said "coming soon" in a C++ thread for the benefit of my health.

Re: My C++ adventures!

Posted: Sat Sep 20, 2008 8:20 am
by ~Earl Grey~
Image

Image