【发布时间】:2016-01-11 18:37:10
【问题描述】:
我正在 C++ Builder 中开发 IOS 应用程序。我的问题是如何在 for 循环中构建 TImages。我公开声明了向量:
#include <vector>
std::vector<TImage*> Image(c); // public declaration
void __fastcall TForm1::Button2Click(TObject *Sender)
{
for (int i = 0; i < c ; i++){
c = 5 // c should be send to te array
Image[i] = new TImage(this); // I tried it this way but when i click the button i get an acess violence error
Image[i]->Parent = BoardItem ;
Image[i]->Height = 20 ;
Image[i]->Width = 20 ;
}
}
那么如何使用向量在 for 循环中创建图像?
Dynamic alocation an array of Images in C++ Builder 我查找了该问题的最后一个答案,但没有描述如何循环执行。
【问题讨论】:
-
当你做
std::vector<TImage*> Image(c);时c的值是多少? -
感谢您的回答,但我的问题已经解决了:)
-
请将您得到的答案作为答案,以帮助他人。
-
@JesseWatZ 我的帮助不足以勾勒出来吗?
-
当我评论时我没有意识到你做了一个。
标签: c++ arrays image dynamic vector