Home > Back-end >  Be urgent! Define a class, class object is the vector, the vector elements are structure, structure
Be urgent! Define a class, class object is the vector, the vector elements are structure, structure

Time:09-29

Environment is VC6.0 is the program I wrote below, always feel not appropriate,, but as a small white and don't know what to do, tomorrow will be made for a great god help see ~ ~
1. The structure of the defined within the class or outside class? Another call when the how to write, you must write CTargetState: : m_vTargetState. M_strTargetPosition. M_dTargetPostionX; Like this?
2. To the Vector medium voltage data about how to write m_vTargetState. Pushback (m_vTargetState) write like this?
3. If I ask the vector medium-pressure five new vector, and then want to invoke the third pressed in the vector, how to call? Use the list? Can directly read? How to implement the c + + code?

 

#include
#include
#include
using namespace std;

Class CTargetState//the class declaration
{
Public:


Private:
Struct m_strTargetPosition//cartesian coordinate position
{
Double m_dTargetPostionX;
Double m_dTargetPostionY;
Double m_dTargetPostionZ;
}
Struct m_strTargetVelocity//speed
{
Double m_dTargetVelocityX;
Double m_dTargetVelocityY;
Double m_dTargetVelocityZ;
}
Struct m_strTargetAccelerate acceleration//
{
Double m_dTargetAccelerateX;
Double m_dTargetAccelerateY;
Double m_dTargetAccelerateZ;
}
Typedef struct m_strTargetState//structure type definition for private use
{
Struct m_strTargetPosition;
Struct m_strTargetVelocity;
Struct m_strTargetAccelerate;
} StruTargetState;

The vector & lt; StruTargetState> M_vTargetState;


};//the endof the class CTargetState

CodePudding user response:

The great god! ~ ~ ~ ~ ~

CodePudding user response:

First three struct definition can be outside, it doesn't matter in
 
Struct m_strTargetPosition//cartesian coordinate position
{
Double m_dTargetPostionX;
Double m_dTargetPostionY;
Double m_dTargetPostionZ;
};

Struct m_strTargetVelocity//speed
{
Double m_dTargetVelocityX;
Double m_dTargetVelocityY;
Double m_dTargetVelocityZ;
};

Struct m_strTargetAccelerate acceleration//
{
Double m_dTargetAccelerateX;
Double m_dTargetAccelerateY;
Double m_dTargetAccelerateZ;
};

Typedef struct m_strTargetState//structure type definition for private use
{
Struct m_strTargetPosition;
Struct m_strTargetVelocity;
Struct m_strTargetAccelerate;
} StruTargetState;

CodePudding user response:

Take the third element,
C.a. t (index); Return to specified index location element
 m_vTargetState. At (2) 

http://www.cnblogs.com/cb168/p/4237244.html

CodePudding user response:

Thanks for the great god upstairs!
  • Related