Convert variables from c# to c++ -


c#

public sealed class rc5     {         private readonly uint[] _bufkey = new uint[4];         private readonly uint[] _bufsub = new uint[26]; }; 

c++(errors)

class rc5 { protected:         unsigned __int32[] _bufkey = new unsigned __int32[4];         unsigned __int32[] _bufsub = new unsigned __int32[26]; }; 

of course got errors in c++ code , don't know how make right can me please?! thanks

  1. in c++ array "marker" must follow variable name, not type name.
  2. you have 2 ways in c++ instantiate array:

a) make fix array:

class rc5 {   protected:     unsigned __int32 _bufkey[4];     unsigned __int32 _bufsub[26]; }; 

b) allocate on heap:

class rc5 {   public:     rc5() :       _bufkey(new unsigned __int32[4]),       _bufsub(new unsigned __int32[26]) {     }     virtual ~rc5() {       delete [] _bufkey;       delete [] _bufsub;     }   protected:     unsigned __int32 *const _bufkey;     unsigned __int32 *const _bufsub; }; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -