定义类c ++中的数组 [英] Definition an array within class c++

查看:305
本文介绍了定义类c ++中的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

我想在一个类中定义一个数组。我的数组是一个动态数组。我有两个解决方案但不起作用。

Hello friends
I want define an array in a class.my Array is a dynamic array.I've two solution but do not work.

我的解决方案是:int myArray = [space]或int * myArry;  ) - :

my solutions are : int myArray=[space] or int *myArry;  )-:

你能帮助我吗?(请参阅此代码)

can you help me?(please see this code)

class myClass{

public:
	myClass(int s){ space = s;
	myArray = new int[space];
     }

private:
	int space;
	int *myArray;// also myArray[space] is not work!!
};

int main(){
myClass obj1(3);   //

return 0;
}




推荐答案

您能详细说明一下您的查询,并告诉我们这是如何与Azure Stack相关的吗?
Could you elaborate more on your query and let us know how this is related to Azure Stack?


这篇关于定义类c ++中的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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