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
- in c++ array "marker" must follow variable name, not type name.
- 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
Post a Comment