How to set data with 0 in C++? -


this question has answer here:

in c set data 0 memset() function (not initialization).

my data changed method , want reuse , want set 0 before reusing

are there way set data 0 in c++ other memset()?

class myclass : public namespace::parentclass {      private:         struct mystruct data      public:         void method(); };  void myclass::method() {     memset(&data, 0, sizeof(data)); // it's c way. there way in c++ } 

in c++ invoke constructor of object, or initialiser primitive constructor-less objects.

re-initialisation should happen (don’t reuse variables, create new ones! makes program flow clearer) – but when need can re-assign new object:

data = mystruct(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -