Hey all,

I have a problem with pointers, one which I am completely unable to comprehend. But first, here's part of the code:

Code:
/* The controling class of the whole program. Calls the functions responsible for displacement calculation and object rendering,
 * as well as containing a pointer to the first object in the linked list
 */

#ifndef CLASS_UNIVERSE_H
    #define CLASS_UNIVERSE_H

#include "ClassStar.h"
#include "ClassValues.h"
#include "ClassMath.h"
#include "ClassGravCalc.h"
#include "ClassRender.h"
#include "ClassPosRegulator.h"


class ClUniverse {
    private:

    ClStar* m_STARS;

    public:

    ClUniverse();

    void calculateDisplacement();
    void drawObjects();
};

#endif
Code:
#include "ClassUniverse.h"
#include <iostream>

using namespace std;

ClUniverse::ClUniverse()
{
    m_STARS = new ClStar(ClValues::nNumObjects);
}

void ClUniverse::calculateDisplacement()
{
    ClStar* curStar = m_STARS;
    ClStar* nxtStar;
    for(int x = 0; x < ClValues::nNumObjects; x++, curStar = curStar->getNextNode()) {
        nxtStar = curStar->getNextNode();
        while(nxtStar != 0) {
            ClGravCalc(*curStar, *nxtStar);
            ClPosRegulator(*curStar);
            cout << curStar << endl;
            cout << (curStar->getPosition()).getX() << endl;
            cout << (curStar->getPosition()).getY() << endl;
            cout << endl;
            nxtStar = nxtStar->getNextNode();
        }
    }
}

//The change of color of the star from center out is given by the function in ClMath, as well as the increase of its transparency
void ClUniverse::drawObjects()
{
    clear(ClValues::dblbuffer);

    ClStar* curStar = m_STARS;

    drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);

    for(int x = 0; x < ClValues::nNumObjects; x++, curStar = curStar->getNextNode())
        ClRender(ClValues::dblbuffer, curStar->getPosition(), curStar->getRadius());

    vsync();
    blit(ClValues::dblbuffer, screen, 0, 0, 0, 0, ClValues::nScreenHight, ClValues::nScreenWidth);
}
Code:
/* This class will wrap around the position of an object if necessary
 */

#ifndef CLASS_POS_REGULATOR_H
    #define CLASS_POS_REGULATOR_H

#include "ClassStar.h"
#include "ClassVector.h"
#include "ClassValues.h"

struct ClPosRegulator {
    ClPosRegulator(ClStar& Star);
};

#endif
Code:
#include "ClassPosRegulator.h"

ClPosRegulator::ClPosRegulator(ClStar& Star)
{
    //Move the object so that the upper left part of the Universe corresponds to [0, 0]
    long int nInvisiblePartHight = (ClValues::dUniverseSize - 1) * ClValues::nScreenHight / 2;
    long int nInvisiblePartWidth = (ClValues::dUniverseSize - 1) * ClValues::nScreenWidth / 2;
    ClVector vecScreen(ClValues::nScreenWidth, ClValues::nScreenHight);
    ClVector vecInvisiblePart(nInvisiblePartWidth, nInvisiblePartHight);
    ClVector vecNewPosition = Star.getPosition() + vecInvisiblePart;

    //Wrap position of object if necessary

    Star.setPosition(vecNewPosition % (ClValues::dUniverseSize * vecScreen) - vecInvisiblePart);
}
I'm attempting to make a simulation of star movement. It works fine, I've long since compiled it. I've been adding and tweaking ever since, and I wanted to add a class (ClPosRegulator) that would wrap the position of the star should it go off the screen. I have a class ClStar which is set up to work as a linked list (as in I have a linked list of ClStars), where m_STARS points to the first node. So what I do in the code above is loop through the "stars", calculate the displacement due to gravity using the function ClGravCalc (already been in use for some time, no problems there) and then attempt to wrap around the position of the stars using ClPosRegulator. Unfortunately, if I try to compile the above code without the cout's, it gives me a warining "unused variable curStar" on the line where I call ClPosRegulator (which is evidently nonsense as I use it before) and the "stars" don't wrap around. If I compile with the cout's, it gives me

error: 'struct ClPosRegulator' has no member named 'getPosition'
error: 'struct ClPosRegulator' has no member named 'getPosition'

If I comment out the problematic cout's (the ones containing calls to getPosition()), it compiles fine, and the remaining cout outputs only zeros. If I place the cout's before the call to ClPosRegulator, it compiles fine and they output the expected values (two values representing XY coordinates, and an address in hexadecimal), so the problem has to be somewhere in ClPosRegulator.

I know I didn't explain the logic behind 90% of the code, because I'm hoping that the error is something one of you can spot without knowing what the purpose of the code is. If you need any additional info, feel compelled to ask for it in a reply.

Cheers,

Gabe