It is currently Thu May 23, 2013 12:26 am Advanced search

Editing PlanetWars.h/.cc

Code won't compile? Found a bug? Post here!

Re: Editing PlanetWars.h/.cc

Postby voidptr » Fri Oct 29, 2010 9:28 pm

Mistmanov wrote:
voidptr wrote:"Wait... this programming competition requires me to write code? That's so lame!" :)


It does sound kinda bad when you say it like that :P

Anyway, I went for the quick and dirty option.. removing all of the "consts" and the "&" signs (have no idea what they do, but eh..),


Briefly and incorrectly, "&" in C++ means the same thing as "*" in C, except that when you use the variable, it has an implied "*" in front of it, and when you initialize the variable, the initializer has an implied "&" in front of it. It's called a "reference", because it can be used to implement pass-by-reference semantics. Look it up for more information.

It seems to do what I want it to do.. so I hope I can now go back to ignoring classes and stuff and pretending I'm coding C.


C++ doesn't force you to use classes, you know; you could rewrite all those member functions as plain old functions taking a parameter of type "struct PlanetWars *thisptr", and then you wouldn't have to worry about references or methods or anything. (Actually, part of my initial rewrite was to change "class" to "struct", remove all the "const" qualifiers, remove all the "public:" and "private:" keywords, and remove all the getter and setter methods, so that I could manipulate the objects without so many redundant() parentheses(). I only wish I'd bothered to remove the underscores from all the fields at that point; by now I've probably wasted at least that much time fixing places where I left off an underscore by accident.)

Or, I believe the server does support regular C now. :)
voidptr
Brigadier-General
 
Posts: 139
Joined: Sun Sep 12, 2010 7:22 pm

Previous

Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest

cron