My C adventures!

Fed up talking videogames? Why?
User avatar
That
Dr. Nyaaa~!
Dr. Nyaaa~!
Joined in 2008

PostRe: My C++ adventures!
by That » Mon Aug 25, 2008 5:40 pm

Code: Select all

#include <iostream>
using namespace std;

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

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

Image
User avatar
That
Dr. Nyaaa~!
Dr. Nyaaa~!
Joined in 2008

PostRe: My C++ adventures!
by That » Mon Aug 25, 2008 7:37 pm

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.

Image
User avatar
i.mosfet
Member
Joined in 2008

PostRe: My C++ adventures!
by i.mosfet » Tue Aug 26, 2008 10:34 am

"Hello World" wouldn't be too much ask Karl...

User avatar
i.mosfet
Member
Joined in 2008

PostRe: My C++ adventures!
by i.mosfet » Thu Aug 28, 2008 1:58 am

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.

User avatar
TS2Master
Member
Joined in 2008

PostRe: My C++ adventures!
by TS2Master » Fri Aug 29, 2008 2:19 pm

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?

I am Weasel.
User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Fri Aug 29, 2008 8:54 pm

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

User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Fri Aug 29, 2008 8:59 pm

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.

User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Fri Aug 29, 2008 9:03 pm

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.

Last edited by ~Earl Grey~ on Wed Jan 14, 2009 3:24 am, edited 1 time in total.
User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Wed Sep 03, 2008 3:30 am

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.

User avatar
Dolph Wiggler
Member
Joined in 2008
Location: 1123,6536,5231
Contact:

PostRe: My C++ adventures!
by Dolph Wiggler » Wed Sep 03, 2008 11:32 am

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?

User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Wed Sep 03, 2008 5:43 pm

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.

User avatar
Johnny Ryall
Member
Joined in 2008
AKA: Macraig
Location: Box Elder, MO

PostRe: My C++ adventures!
by Johnny Ryall » Fri Sep 05, 2008 9:25 pm

I don't know what this is.

User avatar
Oblomov Boblomov
Member
Joined in 2008
AKA: Mind Crime, SSBM_God

PostRe: My C++ adventures!
by Oblomov Boblomov » Mon Sep 08, 2008 4:37 am

Lol geeks.

Image
User avatar
Lex-Man
Member
Joined in 2008
Contact:

PostRe: My C++ adventures!
by Lex-Man » Wed Sep 10, 2008 8:29 pm

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

Amusement under late capitalism is the prolongation of work.
User avatar
Lex-Man
Member
Joined in 2008
Contact:

PostRe: My C++ adventures!
by Lex-Man » Wed Sep 10, 2008 8:30 pm

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.

Amusement under late capitalism is the prolongation of work.
User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Sun Sep 14, 2008 7:48 pm

Image

Image

Coming soon...

User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Thu Sep 18, 2008 9:44 pm

Here's a cool little program I wrote.

User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Fri Sep 19, 2008 3:32 pm

Yeah I did that in the Tonkinfrash days. Still a cool little util though.

The Darkplace game is coming on, too.

User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Fri Sep 19, 2008 6:38 pm

No, I posted 2 images and said "coming soon" in a C++ thread for the benefit of my health.

User avatar
~Earl Grey~
Member
Joined in 2008

PostRe: My C++ adventures!
by ~Earl Grey~ » Sat Sep 20, 2008 8:20 am

Image

Image


Return to “Stuff”

Who is online

Users browsing this forum: floydfreak, Grumpy David, Lex-Man, Met, more heat than light, Ploiper, shy guy 64, TonyDA and 383 guests