将变量从c#转换为c ++ [英] Convert variables from c# to c++

查看:109
本文介绍了将变量从c#转换为c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c#

public sealed class RC5
    {
        private readonly uint[] _bufKey = new uint[4];
        private readonly uint[] _bufSub = new uint[26];
};

c ++(错误)

class RC5
{
protected:
        unsigned __int32[] _bufKey = new unsigned __int32[4];
        unsigned __int32[] _bufSub = new unsigned __int32[26];
};

当然,我在c ++代码中遇到错误,我不知道如何使它正确可以有人请帮帮我?!感谢

Of course I got errors in the c++ code , I don't know how make it right can someone help me please?! Thanks

推荐答案


  1. 在C ++中,数组marker必须跟在变量名称后面, 。

a)使用C ++修复数组:

a) Make it a fix array:

class RC5 {
  protected:
    unsigned __int32 _bufKey[4];
    unsigned __int32 _bufSub[26];
};

b)在堆上分配:

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;
};

这篇关于将变量从c#转换为c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆