0

I have a vector called actorVector which stores an array of objects of type actorManager.

The actorManager class has a private attribute, which is also an object of type GLFrame. It has an accessor, getFrame(), which returns a pointer to the GLFrame object.

I have passed a pointer of actorVector to a function, so its a pointer to a vector of objects of type actorManager.

I need to pass the GLFrame object as a parameter to this function:

modelViewMatrix.MultMatrix(**GLFrame isntance**);

I've currently been trying to do it as such, but im not getting any results.

modelViewMatrix.MultMatrix(*(*actorVector)[i].getFrame());

Any ideas?

2
  • Are you getting a compiler error? Commented Jun 15, 2011 at 0:18
  • 2
    It would be a good idea to show the relevant declarations, as such descriptions aren't really, well, descriptive. Commented Jun 15, 2011 at 0:20

2 Answers 2

3

Assuming MultMatrix takes an ActorManager by value or by reference (as opposed to by pointer), then you want this:

modelViewMatrix.MultMatrix(*((*actorVector)[i].getFrame()));

Note that the precedence rules mean that the above is equivalent to:

modelViewMatrix.MultMatrix(*(*actorVector)[i].getFrame());

However, that's what you already have, so there must be something you're not telling us...

Sign up to request clarification or add additional context in comments.

1 Comment

He said actorVector is a vector, not a pointer, so does *actorVector mean anything? I agree we need more information.
0

Try modelViewMatrix.MultMatrix( *(*p)[i].getFrame() );

#include <vector>
using std::vector;

class GLFrame {};
class actorManager {
  /* The actorManager class has a private attribute, which is also an
  object of type GLFrame. It has an accessor, getFrame(), which returns
  a pointer to the GLFrame object. */
private:
  GLFrame g;
public:
  GLFrame* getFrame() { return &g; }
};

/* I need to pass the GLFrame object as a parameter to this function:
   modelViewMatrix.MultMatrix(**GLFrame isntance**); */
class ModelViewMatrix {
public:
  void MultMatrix(GLFrame g){}
};
ModelViewMatrix modelViewMatrix;

/* I have a vector called actorVector which stores an array of objects of
type actorManager.  */
vector<actorManager> actorVector;

/* I have passed a pointer of actorVector to a function, so its a pointer
to a vector of objects of type actorManager. */
void f(vector<actorManager>* p, int i) {
/* I need to pass the GLFrame object as a parameter to this function:
   modelViewMatrix.MultMatrix(**GLFrame isntance**); */
   modelViewMatrix.MultMatrix( *(*p)[i].getFrame() );
}

int main() {
  f(&actorVector, 1);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.