-1

I'm working with PhysX in C++ and am getting the error,cannot instantiate abstract class in the following code:

std::vector < PxJoint* > joints;
PxD6Joint* j = PxD6JointCreate(*gPhysics, a0, t0, a1, t1);
joints.push_back (j);
(PxD6Joint)(joints[0])->setDrivePosition(PxTransform()); //error here

The code is just an example. PxD6joint is an abstract class that inherits from PxJoint. I figure there must be some way to access the public members of &j via joints[0], but, if there is, I'm not doing it right.

Matt Munson
  • 2,903
  • 5
  • 33
  • 52

1 Answers1

0

As told by Joachim, you are trying to cast the result of setDrivePosition to PxD6Joint type, which is wrong (especially since the method does nots return anything. I guess you are trying somehow to cast the object pointed to by joints[0] to PxD6Joint type, which is useless, it is already of the correct class.

But this class is a pure abstract class : some methods are not implemented (setDrivePosition (const PxTransform &pose)=0). You need to use an object that is of a subclass of PxD6Joint, with all methods implemented.