Declare virtual class

Psuedocode:

virtual struct getLinearAccel();

I know this doesn't work, I need to know why it doesn't work and how to make it work. I ultimately want to be able to return a struct called dV that contains doubles dVx, dVy, dVz.

Thanks.
1
2
3
4
5
6
7
8
9
10
struct dV
{
    double dVx, dVy, dVz;
};

class SomeClass
{
//...
    virtual dV getLinearAccel();
};
 
virtual struct getLinearAccel{};//learn the syntax and Semanitics before posting and check //your code extensively 

you used parentheses instead of brackets :)

edit the example may be wrong in of itself

heres a better one
1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct Vertex
{
  double dX,dY,dZ;//you know its a vertex why prefix with "V" to x or "Y"?
};

class VertexGenerator
{
public:
//a bad design would do this but this is for example's sake
Vertex* getVertex(double x, double y, double z ){return new Vertex{x,y,z};}

void freeVertex(Vertex* v){if(v != 0 ){delete v;}
else{//throw exception here;}}
}

Last edited on
Topic archived. No new replies allowed.