在哪里放置数组初始化? [英] where to place array initialization?
问题描述
你好,
我试图抓住在下面的代码中使用Visual创建两个
数组的初始化的位置C ++ 2005
Express Beta 2 ...
private:静态数组< String ^> ^ LHSquestions = gcnew数组< String ^>
{"问题1","问题2"};
private:静态数组< String ^> ^ RHSquestions = gcnew数组< String ^>
{"问题1",
"问题2"};
我原以为我会在另一个私有之后添加它们线路
以下?有关初学者的互联网教程或使用C ++ Express语言预订
的建议吗?
干杯
Geoff
!
#pragma一次
命名空间trackbar1
{
using namespace System;
using namespace System :: ComponentModel;
using namespace System :: Collections;
using namespace System :: Windows :: Forms;
使用命名空间System :: Data;
使用命名空间System :: Drawing;
/// < summary>
/// Form1摘要
///
///警告:如果更改此类的名称,您将需要为管理的
资源编译工具更改
///''资源文件名''属性
/>
///与所有.resx文件相关联此类
取决于。否则,
///设计师将无法与本地化相关的本地化
///资源进行正确交互
。
///< / summary>
public ref class Form1:public System :: Windows :: Forms :: Form
{
public:
Form1(无效)
{
InitializeComponent();
/ /
// TODO:在这里添加构造函数代码
//
}
protected :
///< summary>
///清理正在使用的所有资源。
///< / summary>
///< param name =" disposing">"
参数的说明"< / param>
virtual void Dispose(布尔处理)覆盖
{
if(处理&&组件)
{
删除组件;
}
__super :: Dispose(disposing);
}
private:System: :视窗:: Forms :: TrackBar ^ trackBar1;
protected:
private:System :: Windows :: Forms :: PictureBox ^ pictureBox1;
private: System :: Windows :: Forms :: Label ^ label1;
private:System :: Windows :: Forms :: Label ^ label2;
private:System :: Windows :: Forms :: Button ^ button1;
private:
///< summary>
///必填设计师变量。
///< / summary>
System :: ComponentModel :: Container ^ components;
# pragma region Windows窗体设计器生成的代码
///< summary>
/// Designer支持所需的方法 - 不要
修改
///使用代码编辑器调用此方法的内容。
///< / summary>
void InitializeComponent(void)
{
System :: ComponentModel :: ComponentResourceManager ^ resources =(gcnew
System :: ComponentModel :: ComponentResourceManager(F orm1 :: typeid));
this-> trackBar1 =(gcnew
System :: Windows :: Forms :: TrackBar());
this-> pictureBox1 =(gcnew
System :: Windows :: Forms :: PictureBox());
this-> label1 =(gcnew
System :: Windows: :Forms :: Label());
this-> label2 =(gcnew
System :: Windows :: Forms :: Label());
this-> button1 =(gcnew
System :: Windows :: Forms :: Button());
(cli: :safe_cast< System :: ComponentModel :: ISupportIn itialize ^
(this-> trackBar1)) - > BeginInit();
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > BeginInit();
this-> SuspendLayout();
//
// trackBar1
//
this-> trackBar1-> Location =
System :: Drawing :: Point(90,168);
this-> trackBar1-> Name = L" trackBar1";
this-> trackBar1-> Size =
System :: Drawing :: Size(104,45);
this-> trackBar1-> TabIndex = 0;
//
// pictureBox1
//
this-> pictureBox1-> Image =
(cli :: safe_cast< System :: Drawing :: Image ^(resources-> GetObject(L" pictureBox1.Image")) );
this-> pictureBox1-> Location =
System :: Drawing :: Point(37,13);
this-> pictureBox1-> ; Name = L" pictureBox1";
this-> pictureBox1-> Size =
System :: Drawing :: Size(212,134);
this-> pictureBox1-> TabIndex = 1;
this-> pictureBox1-> TabStop = false;
//
// label1
//
this-> label1-> AutoSize = true;
this-> label1-> Location =
System :: Drawing :: Point(27,182);
this-> label1-> Name = L" label1" ;;
this-> label1-> Size = System :: Drawing :: Size(31,
13);
this-> ; label1-> TabIndex = 2;
this-> label1-> Text = L" label1";
//
// label2
//
this-> label2-> AutoSize = true;
this-> label2-> Location =
系统::绘图::点(230,182);
this-> label2-> Name = L" la bel2" ;;
this-> label2-> Size = System :: Drawing :: Size(31,
13);
this-> label2-> TabIndex = 3;
this-> label2-> Text = L" label2";
//
//按钮1
//
this-> button1-> Location =
System :: Drawing :: Point( 100,219);
this-> button1-> Name = L" button1";
this-> button1-> Size =
系统::绘图::大小(75,23);
this-> button1-> TabIndex = 4;
this-> button1 - > Text = L" NEXT";
//
// Form1
//
this - > AutoScaleDimensions =
System :: Drawing :: SizeF(6,13);
this-> AutoScaleMode =
系统: :Windows :: Forms :: AutoScaleMode :: Font;
this-> ClientSize = System :: Drawing :: Size(292,
266);
this-> Controls-> Add(this-> button1);
this-> Controls-> Add(this-> label2);
this-> Controls-> Add(this-> label1);
this-> Controls-> Add(this-> pictureBox1);
this-> Controls-> Add(this-> trackBar1);
this-> Name = L" Form1";
this-> Text = L" Form1"
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> trackBar1)) - > EndInit();
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > EndInit();
this-> ResumeLayout(false);
this-> PerformLayout();
}
#pragma endregion
};
}
它''我想是风格问题。
一个选项 - 你可以将所有静态阵列成员放在一起。
另请注意,您不需要指定私人对于每个声明。一个
就可以了。
私有:
静态数组< String ^> ^ LHSquestions = gcnew数组< String ^> ; {"
1","问题2"};
静态数组< String ^> ^ RHSquestions = gcnew数组< String ^> {" ;问题
1","问题2"};
-
问候,
Nish [VC ++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
< Geoff Cox>在消息中写道
news:lu ******************************** @ 4ax.com ...你好,
我试图抓住在下面的代码中使用Visual创建两个
数组的初始化的位置C ++ 2005
Express Beta 2 ...
private:静态数组< String ^> ^ LHSquestions = gcnew数组< String ^>
{"问题1", 问题2};
私有:静态数组< String ^> ^ RHSquestions = gcnew数组< String ^>
{"问题1",
"问题2" }}
我原以为我会把它们添加到下面的其他专线之后?有关使用C ++ Express语言的初学者的互联网教程或书籍的任何建议吗?
Geers
Geoff
!
#pragma一次
命名空间trackbar1
{
使用命名空间系统;
使用命名空间System :: ComponentModel;
使用命名空间System :: Collections;
使用命名空间System :: Windows :: Forms;
使用命名空间System :: Data;
使用命名空间System :: Drawing;
/ //< summary>
/// Form1的摘要
///
///警告:如果更改此类的名称,您将需要更改受管理的
资源编译器工具的
///''资源文件名''属性///与此类
依赖的所有.resx文件相关联。否则,
///设计师将无法正确地与本表格相关的本地化资源进行互动。
///< / summary> <公共引用类Form1:public System :: Windows :: Forms :: Form
{
公共:
Form1(void)
{/> InitializeComponent() ;
//
// TODO:在这里添加构造函数代码
//
}
受保护:
///<摘要>
///清理正在使用的所有资源。
///< / summary>
///< param name =" disposing">" description of
参数"< / param>
虚拟空置Dispose(布尔处理)覆盖
{
if(处理&&组件)
{
删除组件;
} __super :: Dispose(disposing);
}
private:System :: Windows :: Forms :: TrackBar ^ trackBar1;
protected :
private:System :: Windows :: Forms :: PictureBox ^ pictureBox1;
private:System :: Windows :: For ms :: Label ^ label1;
private:System :: Windows :: Forms :: Label ^ label2;
private:System :: Windows :: Forms :: Button ^ button1;
<私有:
///< summary>
///所需的设计变量。
///< / summary>
System :: ComponentModel :: Container ^组件;
#pragma region Windows窗体设计器生成的代码
///< summary>
///支持Designer的必需方法 - 不要修改
///使用代码编辑器的方法的内容。
///< / summary>
void InitializeComponent(void)
> System :: ComponentModel :: ComponentResourceManager ^ resources =(gcnew
System :: ComponentModel :: ComponentResourceManager(F orm1 :: typeid));
this-> trackBar1 =(gcnew
System :: Windows :: Forms :: TrackBar());
this-> pictureBox1 =(gcnew
System :: Windows :: Forms :: PictureBox());
this-> ; label1 =(gcnew
System :: Windows :: Forms :: Label());
this-> label2 =(gc新的
系统:: Windows :: Forms :: Label());
this-> button1 =(gcnew
System :: Windows :: Forms :: Button());
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> trackBar1)) - > BeginInit();
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > BeginInit();
this-> SuspendLayout();
//
// trackBar1
//
this-> trackBar1->位置=
系统: :Drawing :: Point(90,168);
this-> trackBar1-> Name = L" trackBar1";
this-> trackBar1-> Size =
系统: :Drawing :: Size(104,45);
this-> trackBar1-> TabIndex = 0;
//
// pictureBox1
//
this-> pictureBox1-> Image =
(cli :: safe_cast< System :: Drawing :: Image ^(resources-> GetObject(L" pictureBox1.Image") ));
this-> pictureBox1-> Location =
System :: Drawing :: Point(37,13);
this-> pictureBox1-> Name = L" pictureBox1";
this-> pictureBox1-> Size =
System :: Drawing :: Size(212,134);
this-> pictureBox1-> TabIndex = 1;
this-> ; pictureBox1-> TabStop = false;
//
// label1
//
this-> label1-> AutoSize = true;
这个 - > label1-> Location =
System :: Drawing :: Point(27,182);
this-> label1-> Name = L" label1";
this- > label1-> Size = System :: Drawing :: Size(31,
13);
this-> label1-> TabIndex = 2;
this-> label1 - > Text = L" label1";
//
// label2
//
this-> label2-> AutoSize = true;
这个 - > label2-> Location =
System :: Drawing :: Point(230,182);
this-> label2-> Name = L" label2";
this - > label2-> Size = System :: Drawing :: Size(31,
13);
this-> label2-> TabIndex = 3;
this-> label2-> Text = L" label2";
//
// button1
//
this-> button1-> Location =
System :: Drawing :: Point(100,219);
this-> button1-> Name = L" button1";
this-> button1-> Size =
System :: Drawing :: Size(75,23);
this-> button1-> TabIndex = 4;
this-> button1-> Text = L" NEXT" ;
//
// Form1
//
this-> AutoScaleDimensions =
System :: Drawing :: SizeF(6,13);
this-> AutoScaleMode =
System :: Windows :: Forms :: AutoScaleMode :: Font;
this-> ClientSize = System :: Drawing :: Size(292,
266);
this-> Controls-> Add(this-> button1);
this-> Controls-> Add(this-> label2);
this - > Controls-> Add(this-> label1);
this-> Controls-> Add(this-> pictureBox1);
this-> Controls-> Add (this-> trackBar1);
this-> Name = L" Form1";
this-> Text = L" Form1";
(cl i :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> trackBar1)) - > EndInit();
( cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > EndInit();
this-> ResumeLayout (false);
this-> PerformLayout();
}
#pragma endregion
};
}
2005年8月17日星期三14:31:06 +0530,Nishant Sivakumar
< ni ** @ nospam .asianetindia.com>写道:
我猜这是一个风格问题。
Nish,
如果你像我一样多的C ++初学者,那就没有了!我发现如果
我将它们放在下面,那么构建工作就可以了。我无法锻炼如何
声明/初始化一个名为qnumber的int,以便我可以拥有
LHSquestions [qnumber]
我该怎么做?我会在哪里放一些像
private:int qnumber = 0;
干杯
Geoff
#pragma一次
命名空间trackbar1
{
使用命名空间系统;
使用命名空间System :: ComponentModel;
使用命名空间System :: Collections;
使用命名空间System :: Windows :: Forms;
使用命名空间System :: Data;
使用命名空间System :: Drawing;
///< summary>
/// Form1的摘要
///
///警告:如果你改变这个类的名字,你将
需要为托管的
资源编译工具更改
///''资源文件名''属性
///关联所有.resx文件这个类
取决于。否则,
///设计师将无法与本地化相关的本地化
///资源进行正确交互
。
///< / summary>
public ref class Form1:public System :: Windows :: Forms :: Form
{
public:
Form1(无效)
{
InitializeComponent();
/ /
// TODO:在这里添加构造函数代码
//
this-> label1-> Text = LHSquestions [qnumber];
this-> label2-> Text = RHSquestions [qnumber];
}
protected :
///< summary>
///清理正在使用的所有资源。
///< / summary>
///< param name =" disposing">"
参数的说明"< / param>
virtual void Dispose(布尔处理)覆盖
{
if(处理&& components)
{
删除组件;
}
__super :: Dispose(disposing);
}
private:System :: Windows :: Forms :: TrackBar ^ trackBar1;
protected:
private:System :: Windows :: Forms :: PictureBox ^ pictureBox1;
private:System :: Windows :: Forms :: Label ^ label1;
private:System :: Windows :: Forms :: Label ^ label2;
private:System :: Windows :: Forms :: Button ^ button1;
private:静态数组< String ^> ^ LHSquestions = gcnew
阵列<字符串^> {"问题1","问题2"};
private:静态数组< String ^> ^ RHSquestions = gcnew
array< String ^> {"问题1","问题2"};
私人:
///< summary>
///所需的设计变量。
///< / summary>
System :: ComponentModel :: Container ^ components;
#pragma region Windows窗体设计器生成的代码
///< summary>
///设计器支持所需的方法 - 不要
使用代码编辑器修改
///此方法的内容。
///< / summary>
void InitializeComponent(void)
{
System :: ComponentModel :: ComponentResourceManager ^ resources =(gcnew
System :: ComponentModel :: ComponentResourceManager(F orm1 :: typeid));
this-> trackBar1 =(gcnew
System :: Windows :: Forms :: TrackBar());
this-> pictureBox1 =(gcnew
System :: Windows :: Forms :: PictureBox());
this-> label1 =(gcnew
System :: Windows :: Forms :: Label());
this-> label2 =(gcnew
System :: Windows :: Forms :: Label());
this-> button1 =(gcnew
System :: Windows :: Forms :: Button());
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(这 - > trackBar1)) - > BeginInit在();
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > BeginInit();
this-> SuspendLayout();
//
// trackBar1
//
this-> trackBar1-> Location =
System :: Drawing :: Point(90,168);
this-> trackBar1-> Name = L" trackBar1";
this-> trackBar1-> Size =
System :: Drawing :: Size(104,45);
this-> trackBar1-> TabIndex = 0;
this-> trackBar1-> Scroll + = gcnew
System :: EventHandler(this,& ; Form1 :: trackBar1_Scroll);
//
// pictureBox1
//
this-> pictureBox1-> Image =
(cli :: safe_cast< System :: Drawing :: Image ^(resources-> GetObject(L" pictureBox1.Image")));
this-> pictureBox1-> Location =
System :: Drawing :: Point(37,13);
this-> pictureBox1-> ; Name = L" pictureBox1";
this-> pictureBox1-> Size =
System :: Drawing :: Size(212,134);
this-> pictureBox1-> TabIndex = 1;
this-> pictureBox1-> TabStop = false;
//
// label1
//
this-> label1-> AutoSize = true;
this-> label1-> Location =
System :: Drawing :: Point(27,182);
this-> label1-> Name = L" label1" ;;
this-> label1-> Size = System :: Drawing :: Size(31,
13);
this-> ; label1-> TabIndex = 2;
this-> label1-> Text = L" label1";
//
// label2
//
this-> label2-> AutoSize = true;
this-> label2-> Location =
系统::绘图::点(230,182);
this-> label2-> Name = L" la bel2" ;;
this-> label2-> Size = System :: Drawing :: Size(31,
13);
this-> label2-> TabIndex = 3;
this-> label2-> Text = L" label2";
//
//按钮1
//
this-> button1-> Location =
System :: Drawing :: Point( 100,219);
this-> button1-> Name = L" button1";
this-> button1-> Size =
系统::绘图::大小(75,23);
this-> button1-> TabIndex = 4;
this-> button1 - > Text = L" NEXT";
this-> button1-> Click + = gcnew
System :: EventHandler(this,& Form1 :: button1_Click);
//
// Form1
//
this-> AutoScaleDimensions =
System :: Drawing :: SizeF(6,13);
this-> AutoScaleMode =
System :: Windows :: Forms :: AutoScaleMode :: Font;
this-> ClientSize = System :: Drawing :: Size(292,
266);
this-> Controls-> Add(this-> button1);
this-> Controls-> Add(this-> label2);
this-> Controls-> Add(this-> label1);
this-> Controls-> Add(this-> pictureBox1);
this-> Controls-> Add(this-> trackBar1);
this-> Name = L" Form1";
this- > Text = L" Form1";
this-> Load + = gcnew System :: EventHandler(this,
& Form1 :: Form1_Load);
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> trackBar1)) - > EndInit();
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > EndInit();
this-> ResumeLayout(false);
this-> PerformLayout();
}
#pragma endregion
private:System :: Void button1_Click(System :: Object ^ sender,
System :: EventArgs ^ e){
++ qnumber;
this-> label1-> Text = LHSquestions [qnumber];
this-> label2-> Text = RHSquestions [qnumber];
}
private:System :: Void trackBar1_Scroll(System :: Object ^ sender,
System :: EventArgs ^ e){
}
private:System :: Void Form1_Load(System :: Object ^ sender,
System :: EventArgs ^ e){
}
};
}
一个选项 - 你可以把所有静态数组成员在一起。
另请注意,您不需要指定私有成员。对于每个声明。一个
会这样做。
私人:
静态数组< String ^> ^ LHSquestions = gcnew数组< String ^> {" question
1", "问题2"};
静态数组< String ^> ^ RHSquestions = gcnew数组< String ^> {"问题
1","问题2"};
>如果你像我一样多的C ++初学者,那就不是了!我发现如果我把它们放在下面的构建工作中。我无法锻炼如何声明/初始化一个名为qnumber的int,以便我可以拥有
LHSquestions [qnumber]
我该怎么做?我会在哪里放置像
private:int qnumber = 0;
您无法初始化非静态成员。要么使它静止(如果它符合您的目的)或使用初始化列表。
例如: -
ref class Test
{
private:
static int count = 10;
int x;
public:
Test():x(10)
{
}
};
-
问候,
Nish [VC ++ MVP]
http://www.voidnish.com
< a rel =nofollowhref =http://blog.voidnish.comtarget =_ blank> http://blog.voidnish.com
< Geoff Cox> ;在消息中写道
news:lo ******************************** @ 4ax.com ... 2005年8月17日星期三14:31:06 +0530,Nishant Sivakumar
< ni ** @ nospam.asianetindia.com>写道:
这是风格问题我想。
Nish,
如果你是和我一样多的C ++初学者!我发现如果我把它们放在下面,那么构建工作就可以了。我无法锻炼如何声明/初始化一个名为qnumber的int,以便我可以拥有
LHSquestions [qnumber]
我该怎么做?我会把它放在哪里像
私人:int qnumber = 0;
干杯
Geoff
#pragma once
命名空间trackbar1
{
使用命名空间系统;
使用命名空间System :: ComponentModel;
使用命名空间System :: Collections;
使用namespace System :: Windows :: Forms;
using namespace System :: Data;
using namespace System :: Drawing;
///< summary>
/// Form1的摘要
///
///警告:如果你改变这个类的名字,你将需要更改
///'''托管
资源编译器工具的资源文件名''属性
///与此类
依赖的所有.resx文件相关联。否则,
///设计师将无法正确地与本表格相关的本地化资源进行互动。
///< / summary> <公共引用类Form1:公共系统:: Windows :: Forms ::表格
公共:
Form1(无效)
{
InitializeComponent();
//
// TODO:在这里添加构造函数代码
//
this-> label1-> Text = LHSquestions [ qnumber];
this-> label2-> Text = RHSquestions [qnumber];
}
受保护:
///<摘要>
///清理正在使用的所有资源。
///< / summary>
///< param name =" disposing">" description of
参数"< / param>
虚拟空置Dispose(布尔处理)覆盖
{
if(处理&&组件)
{
删除组件;
} __super :: Dispose(disposing);
}
private:System :: Windows :: Forms :: TrackBar ^ trackBar1;
protected:
private:System :: Windows :: Forms :: PictureBox ^ pictureBox1;
private:System :: Windows :: Forms :: Label ^ label1;
private:System :: Windows :: Forms :: Label ^ label2;
private:System :: Windows :: Forms :: Button ^ button1;
private:static array< String ^> ; ^ LHSquestions = gcnew
array< String ^> {"问题1","问题2"};
private:静态数组< String ^> ^ RHSquestions = gcnew
数组< String ^> {"问题1","问题2"};
私人:
///< summary>
///所需的设计师变量。
///< / summary>
System :: ComponentModel :: Container ^ components;
#pragma region Windows窗体设计器生成的代码
///< summary>
/// Designer支持所需的方法 - 不要使用代码编辑器修改
///此方法的内容。
///< / summary>
void InitializeComponent(void)
System :: ComponentModel :: ComponentResourceManager ^ resources =(gcnew
System :: ComponentModel :: ComponentResourceManager(F orm1 :: typeid) );
this-> trackBar1 =(gcnew
System :: Windows :: Forms :: TrackBar());
this-> pictureBox1 =(gcnew
系统: :Windows :: Forms :: PictureBox());
this-> label1 =(gcnew
System :: Windows :: Forms :: Label());
this-> label2 =(gcnew
System :: Windows :: Forms :: Label());
this-> button1 =(gcnew
System :: Windows :: Forms :: Button());
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> trackBar1)) - > BeginInit();
(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > BeginInit();
this-> SuspendLayout();
//
// trackBar1
//
这个 - > trackBar1-> Location =
System :: Drawing :: Point(90,168);
this-> trackBar1-> Name = L" trackBar1";
this - > trackBar1-> Size =
System :: Drawing :: Size(104,45);
this-> trackBar1-> TabIndex = 0;
this-> trackBar1-> Scroll + = gcnew
System :: EventHandler(this,& Form1 :: trackBar1_Scroll);
//
// pictureBox1
//
this-> pictureBox1-> Image =
(cli :: safe_cast< System :: Drawing :: Image ^(resources-> GetObject(L" pictureBox1.Image& quot;)));
this-> pictureBox1-> Location =
System :: Drawing :: Point(37,13);
this-> pictureBox1 - > Name = L" pictureBox1";
this-> pictureBox1-> Size =
System :: Drawing :: Size(212,134);
this-> pictureBox1 - > TabIndex = 1;
this-> pictureBox1-> TabStop = false;
//
// label1
//
this-> label1-> AutoSize = true;
this-> label1-> Location =
System :: Drawing :: Point(27,182);
this-> label1-> ;Name = L"label1";
this->label1->Size = System::Drawing::Size(31,
13);
this->label1-> ;TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this-> ;label2->AutoSize = true;
this->label2->Location =
System::Drawing::Point(230, 182);
this->label2- >Name = L"label2";
this->label2->Size = System::Drawing::Size(31,
13);
this-> ;label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// button1
//
this->button1->Location =
System::Drawing::Point(100, 219);
this->button1->Name = L"button1";
this->button1->Size =
System::Drawing::Size(75, 23);
this->button1->TabIndex = 4;
this->button1->Text = L"NEXT";
this->button1->Click += gcnew
System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions =
System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292,
266);
this->Controls->Add(this->button1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->pictureBox1);
this->Contro ls->Add(this->trackBar1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
++qnumber;
this->label1->Text = LHSquestions[qnumber];
this->label2->Text = RHSquestions[qnumber];
}
private: System::Void trackBar1_Scroll(System::Object^ sender,
System::EventArgs^ e) {
}
private: System:: Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
}
};
}
One option - You could put all your static array members together.
Also note that you don’’t need to specify "private" for each declaration.
One
would do.
private:
static array<String^>^ LHSquestions = gcnew array<String^>{"question
1","question 2"};
static array<String^>^ RHSquestions = gcnew array<String^>{"question
1","question 2"};
Hello,
I am trying to get a grip on where to place the initialization of two
arrays in the code below which was created using Visual C++ 2005
Express Beta 2...
private: static array<String^>^ LHSquestions = gcnew array<String^>
{"question 1","question 2"};
private: static array<String^>^ RHSquestions = gcnew array<String^>
{"question 1",
"question 2"};
I had assumed that I would add them after the other private lines
below? Any suggestions for a beginner''s Internet tutorial or book on
using C++ Express language?
Cheers
Geoff
!
#pragma once
namespace trackbar1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will
need to change the
/// ''Resource File Name'' property for the managed
resource compiler tool
/// associated with all .resx files this class
depends on. Otherwise,
/// the designers will not be able to interact
properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::TrackBar^ trackBar1;
protected:
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ button1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());
this->pictureBox1 = (gcnew
System::Windows::Forms::PictureBox());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->button1 = (gcnew
System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^
(this->trackBar1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->BeginInit(); this->SuspendLayout();
//
// trackBar1
//
this->trackBar1->Location =
System::Drawing::Point(90, 168);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System::Drawing::Size(104, 45);
this->trackBar1->TabIndex = 0;
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System::Drawing::Image^(resources->GetObject(L"pictureBox1.Image"))); this->pictureBox1->Location =
System::Drawing::Point(37, 13);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System::Drawing::Size(212, 134);
this->pictureBox1->TabIndex = 1;
this->pictureBox1->TabStop = false;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System::Drawing::Point(27, 182);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System::Drawing::Point(230, 182);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// button1
//
this->button1->Location =
System::Drawing::Point(100, 219);
this->button1->Name = L"button1";
this->button1->Size =
System::Drawing::Size(75, 23);
this->button1->TabIndex = 4;
this->button1->Text = L"NEXT";
//
// Form1
//
this->AutoScaleDimensions =
System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292,
266);
this->Controls->Add(this->button1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->trackBar1);
this->Name = L"Form1";
this->Text = L"Form1";
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
};
}
It''s a matter of style I guess.
One option - You could put all your static array members together.
Also note that you don''t need to specify "private" for each declaration. One
would do.
private:
static array<String^>^ LHSquestions = gcnew array<String^>{"question
1","question 2"};
static array<String^>^ RHSquestions = gcnew array<String^>{"question
1","question 2"};
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
<Geoff Cox> wrote in message
news:lu********************************@4ax.com...Hello,
I am trying to get a grip on where to place the initialization of two
arrays in the code below which was created using Visual C++ 2005
Express Beta 2...
private: static array<String^>^ LHSquestions = gcnew array<String^>
{"question 1","question 2"};
private: static array<String^>^ RHSquestions = gcnew array<String^>
{"question 1",
"question 2"};
I had assumed that I would add them after the other private lines
below? Any suggestions for a beginner''s Internet tutorial or book on
using C++ Express language?
Cheers
Geoff
!
#pragma once
namespace trackbar1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will
need to change the
/// ''Resource File Name'' property for the managed
resource compiler tool
/// associated with all .resx files this class
depends on. Otherwise,
/// the designers will not be able to interact
properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::TrackBar^ trackBar1;
protected:
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ button1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());
this->pictureBox1 = (gcnew
System::Windows::Forms::PictureBox());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->button1 = (gcnew
System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->BeginInit();
this->SuspendLayout();
//
// trackBar1
//
this->trackBar1->Location =
System::Drawing::Point(90, 168);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System::Drawing::Size(104, 45);
this->trackBar1->TabIndex = 0;
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System::Drawing::Image^(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location =
System::Drawing::Point(37, 13);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System::Drawing::Size(212, 134);
this->pictureBox1->TabIndex = 1;
this->pictureBox1->TabStop = false;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System::Drawing::Point(27, 182);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System::Drawing::Point(230, 182);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// button1
//
this->button1->Location =
System::Drawing::Point(100, 219);
this->button1->Name = L"button1";
this->button1->Size =
System::Drawing::Size(75, 23);
this->button1->TabIndex = 4;
this->button1->Text = L"NEXT";
//
// Form1
//
this->AutoScaleDimensions =
System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292,
266);
this->Controls->Add(this->button1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->trackBar1);
this->Name = L"Form1";
this->Text = L"Form1";
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
};
}
On Wed, 17 Aug 2005 14:31:06 +0530, "Nishant Sivakumar"
<ni**@nospam.asianetindia.com> wrote:
It''s a matter of style I guess.
Nish,
Not if you are as much of a C++ beginner as I am! I have found that if
I put them as below the build works. I cannot workout how to
declare/initialize an int called qnumber so that I can have
LHSquestions[qnumber]
How do I do this? Where would I put something like
private: int qnumber = 0;
Cheers
Geoff
#pragma once
namespace trackbar1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will
need to change the
/// ''Resource File Name'' property for the managed
resource compiler tool
/// associated with all .resx files this class
depends on. Otherwise,
/// the designers will not be able to interact
properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
this->label1->Text = LHSquestions[qnumber];
this->label2->Text = RHSquestions[qnumber];
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::TrackBar^ trackBar1;
protected:
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ button1;
private: static array<String^>^ LHSquestions = gcnew
array<String^> {"question 1", "question 2"};
private: static array<String^>^ RHSquestions = gcnew
array<String^> {"question 1", "question 2"};
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());
this->pictureBox1 = (gcnew
System::Windows::Forms::PictureBox());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->button1 = (gcnew
System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->BeginInit(); this->SuspendLayout();
//
// trackBar1
//
this->trackBar1->Location =
System::Drawing::Point(90, 168);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System::Drawing::Size(104, 45);
this->trackBar1->TabIndex = 0;
this->trackBar1->Scroll += gcnew
System::EventHandler(this, &Form1::trackBar1_Scroll);
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System::Drawing::Image^(resources->GetObject(L"pictureBox1.Image"))); this->pictureBox1->Location =
System::Drawing::Point(37, 13);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System::Drawing::Size(212, 134);
this->pictureBox1->TabIndex = 1;
this->pictureBox1->TabStop = false;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System::Drawing::Point(27, 182);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System::Drawing::Point(230, 182);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// button1
//
this->button1->Location =
System::Drawing::Point(100, 219);
this->button1->Name = L"button1";
this->button1->Size =
System::Drawing::Size(75, 23);
this->button1->TabIndex = 4;
this->button1->Text = L"NEXT";
this->button1->Click += gcnew
System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions =
System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292,
266);
this->Controls->Add(this->button1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->trackBar1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->EndInit(); this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
++qnumber;
this->label1->Text = LHSquestions[qnumber];
this->label2->Text = RHSquestions[qnumber];
}
private: System::Void trackBar1_Scroll(System::Object^ sender,
System::EventArgs^ e) {
}
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
}
};
}
One option - You could put all your static array members together.
Also note that you don''t need to specify "private" for each declaration. One
would do.
private:
static array<String^>^ LHSquestions = gcnew array<String^>{"question
1","question 2"};
static array<String^>^ RHSquestions = gcnew array<String^>{"question
1","question 2"};
> Not if you are as much of a C++ beginner as I am! I have found that ifI put them as below the build works. I cannot workout how to
declare/initialize an int called qnumber so that I can have
LHSquestions[qnumber]
How do I do this? Where would I put something like
private: int qnumber = 0;
You cannot initialize a non-static member. Either make it static (if it
suites your purpose) or use an initialization list.
E.g. :-
ref class Test
{
private:
static int count = 10;
int x;
public:
Test():x(10)
{
}
};
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
<Geoff Cox> wrote in message
news:lo********************************@4ax.com... On Wed, 17 Aug 2005 14:31:06 +0530, "Nishant Sivakumar"
<ni**@nospam.asianetindia.com> wrote:It''s a matter of style I guess.
Nish,
Not if you are as much of a C++ beginner as I am! I have found that if
I put them as below the build works. I cannot workout how to
declare/initialize an int called qnumber so that I can have
LHSquestions[qnumber]
How do I do this? Where would I put something like
private: int qnumber = 0;
Cheers
Geoff
#pragma once
namespace trackbar1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will
need to change the
/// ''Resource File Name'' property for the managed
resource compiler tool
/// associated with all .resx files this class
depends on. Otherwise,
/// the designers will not be able to interact
properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
this->label1->Text = LHSquestions[qnumber];
this->label2->Text = RHSquestions[qnumber];
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::TrackBar^ trackBar1;
protected:
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ button1;
private: static array<String^>^ LHSquestions = gcnew
array<String^> {"question 1", "question 2"};
private: static array<String^>^ RHSquestions = gcnew
array<String^> {"question 1", "question 2"};
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());
this->pictureBox1 = (gcnew
System::Windows::Forms::PictureBox());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->button1 = (gcnew
System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->BeginInit();
this->SuspendLayout();
//
// trackBar1
//
this->trackBar1->Location =
System::Drawing::Point(90, 168);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System::Drawing::Size(104, 45);
this->trackBar1->TabIndex = 0;
this->trackBar1->Scroll += gcnew
System::EventHandler(this, &Form1::trackBar1_Scroll);
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System::Drawing::Image^(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location =
System::Drawing::Point(37, 13);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System::Drawing::Size(212, 134);
this->pictureBox1->TabIndex = 1;
this->pictureBox1->TabStop = false;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System::Drawing::Point(27, 182);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System::Drawing::Point(230, 182);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// button1
//
this->button1->Location =
System::Drawing::Point(100, 219);
this->button1->Name = L"button1";
this->button1->Size =
System::Drawing::Size(75, 23);
this->button1->TabIndex = 4;
this->button1->Text = L"NEXT";
this->button1->Click += gcnew
System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions =
System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292,
266);
this->Controls->Add(this->button1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->trackBar1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
++qnumber;
this->label1->Text = LHSquestions[qnumber];
this->label2->Text = RHSquestions[qnumber];
}
private: System::Void trackBar1_Scroll(System::Object^ sender,
System::EventArgs^ e) {
}
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
}
};
}
One option - You could put all your static array members together.
Also note that you don''t need to specify "private" for each declaration.
One
would do.
private:
static array<String^>^ LHSquestions = gcnew array<String^>{"question
1","question 2"};
static array<String^>^ RHSquestions = gcnew array<String^>{"question
1","question 2"};
这篇关于在哪里放置数组初始化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!