vendredi 6 septembre 2019

Can i make a template to change class variables

I have a class with data members.

class Sph
{
public:
    Sph( float radius , float segments , const Shader& shader );
    Sph(const Sph& geometry);
    Sph& operator = (const Sph& geometry);
    ~Sph();
    void init();
    void CleanUp();
    void draw();
    void CreateUI(QFormLayout* layout);
    std::vector< Sum_Vertices > GetVertices();

private:
    float Radius,Segments;
    bool isInited;
    unsigned int m_VAO, m_VBO , m_IBO;
    int iNumsToDraw;
    bool isChanged;
    Shader shader;
    int indexCount;
};

in order to change the data of the class i can write individual functions.

void SetRadius( float radius )
{
   this->Radius = radius;
}

is it possible to write a templated function which can change different data members of the class.

Aucun commentaire:

Enregistrer un commentaire