Those two functions are used to update the positions due to the effects of gravity, and "wrap" the star's position if it goes off screen. I was wondering though, when dereferencing the iterator, it...
Type: Posts; User: G4B3
Those two functions are used to update the positions due to the effects of gravity, and "wrap" the star's position if it goes off screen. I was wondering though, when dereferencing the iterator, it...
I was passing references in the original code, but I just haven't gotten around to rewriting it to use lists/iterators. The prototypes for the two highlighted functions are:
void...
Oh...I though the constructor was called for every object. So something like this?
ClUniverse::ClUniverse()
{
for(int x = 0; x < ClValues::nNumObjects; x++) {
ClStar TheStar;
...
*blush* that is an embarrassingly obvious solution isn't it...
Anyway, did that, and it did help a little bit. Turns out the constructor only gets called once, or so it seems. s_nNumStars is...
I call srand() in an initiation class that I haven't posted, but it get's called. It did before, and I haven't touched that code since I wrote it. As for adding anything to the list, shouldn't that...
Hey all,
I have a list of classes enclosed in a class:
/* The controling class of the whole program. Calls the functions responsible for displacement calculation and object rendering,
*...
advance() was the function I was looking for. Thanks, I completely missed it in the reference.
Cheers,
Gabe
PS.: Sorry about the + sizeof(TheClass) thing, I mixed things up in my head and...
Hey all,
I have a list of classes, and two iterators, it_cur and it_nxt. It_cur points to some element, and I need it_nxt to point to the element after it_cur. Is there any simple built in way to...
First of all, it's cin >> FileName. Second, you're missing a parenthesis on the next line. Third, in the inChar function, what are the arguments supposed to be? If the first one was supposed to be a...
Okay, one more question. I have a class that's made up entirely of static variables used throughout the program, such as screen size, number of objects, and general stuff like that. I'm next to...
Well...that changes things. Okay, I'll have a look as soon as I get back.
That would fit, since I was learning Java for a while a couple of months back. In that case, where should I declare...
As I said, that part is preference; I just prefer not to have functions declared basically in the middle of nowhere. I always prefer to have an object containing the function I need, even if that...
Hey, all right already :-D I get the message. I'll be a good boy from now on. Is converting it to a function object the right thing to do?
Well it seem very OOP to me. You need something done, and to get that something done, you have to build something else. So you build the something else, run the original something through it, and...
Preference, I guess. Is there any disadvantage?
And that fact that the compiler considers it a redeclaration (it's already declared a few lines above) baffles me as much as the consequences. Any...
Hey all,
I have a problem with pointers, one which I am completely unable to comprehend. But first, here's part of the code:
/* The controling class of the whole program. Calls the functions...
Wow, never heard of that before. Thanks laserlight ;-)
Thanks for the responses. I know you're not supposed to do that even when mommy's not watching, as I said I was just playing around.
Anon: I'm not sure I understand what's going on there...I've...
Hey all,
class Test {
int m_Val;
public:
void printVal() { cout << m_Val << endl; }
I guess this goes hand in hand with a problem I had when I first compiled the program, when for some reason ClassMath.h had "compile file" and "link file" checked in its properties. Anyway, I fixed...
Oh...well, again because of personal preference, I decided to include all the files in the headers, since the .cpp files include the headers plus everything the headers include. Didn't know it could...
ClassMath is only dependent on <cmath>, <cstdlib> and "ClassRange.h". It needs the former two and while it doesn't need the last, I still don't see how that could be preventing a successful...
Well, when I include the definition in the class, as in
#ifndef CLASS_MATH_H
#define CLASS_MATH_H
#include <cmath>
#include <cstdlib>
#include "ClassRange.h"
Sure, although I doubt that will help you much; main is a mess, I haven't cleaned it up yet, and ClassRange has been used in a couple of programs before without any problems
//ClassRange.h
...
Yup. The program works fine, I'm just tweaking it a bit so it'll look better, and once I add that function it won't compile.