kvs.hです
コード:
#include <string>
#include <iostream>
#include "iteminfo.h"
//void setitemname(String^,int);
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace std;
namespace test {
/// <summary>
/// KVS の概要
///
/// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた
/// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
/// 変更する必要があります。この変更を行わないと、
/// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、
/// 正しく相互に利用できなくなります。
/// </summary>
public ref class KVS : public System::Windows::Forms::Form
{
private:
String^ name;
public:
KVS(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
}
void setitemname(string name,int cnt){
cnt=0;//入力数の初期化
KVS::label1->Text=iteminfo::HB::price;
}
protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~KVS()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private:
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(26, 334);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(118, 37);
this->button1->TabIndex = 0;
this->button1->Text = L"←";
this->button1->UseVisualStyleBackColor = true;
//
// button2
//
this->button2->Location = System::Drawing::Point(150, 334);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(118, 37);
this->button2->TabIndex = 1;
this->button2->Text = L"→";
this->button2->UseVisualStyleBackColor = true;
//
// button3
//
this->button3->Location = System::Drawing::Point(26, 378);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(118, 37);
this->button3->TabIndex = 2;
this->button3->Text = L"ズーム";
this->button3->UseVisualStyleBackColor = true;
//
// button4
//
this->button4->Location = System::Drawing::Point(150, 378);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(118, 37);
this->button4->TabIndex = 3;
this->button4->Text = L"サーブ";
this->button4->UseVisualStyleBackColor = true;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(21, 22);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(0, 12);
this->label1->TabIndex = 4;
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(148, 22);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(0, 12);
this->label2->TabIndex = 5;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(24, 178);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(0, 12);
this->label3->TabIndex = 6;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(148, 178);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(0, 12);
this->label4->TabIndex = 7;
//
// KVS
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(295, 415);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"KVS";
this->StartPosition = System::Windows::Forms::FormStartPosition::Manual;
this->Text = L"KVS";
this->Load += gcnew System::EventHandler(this, &KVS::KVS_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void KVS_Load(System::Object^ sender, System::EventArgs^ e) {
}
};
}
iteminfo.hです
ここにクラスをつくってここの itemname という変数をlabel.textに代入?したいです
コード:
#include <string.h>
using namespace std;
class iteminfo{
class HB{
public:
String itemname="HB";
int price=100;
}
};
エラー文です
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C2146: 構文エラー : ';' が、識別子 'itemname' の前に必要です。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C2864: 'iteminfo::HB::itemname' : スタティック const 整数データ メンバ以外をクラス内で初期化することはできません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(8) : error C2864: 'iteminfo::HB::price' : スタティック const 整数データ メンバ以外をクラス内で初期化することはできません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(10) : error C2059: 構文エラー : '}'
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(10) : error C2143: 構文エラー : ';' が '}' の前にありません。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(10) : error C2238: ';' の前に無効なトークンがあります。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\KVS.h(41) : error C2597: 静的でないメンバ 'iteminfo::HB::price' への参照が正しくありません。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\KVS.h(41) : error C3867: 'iteminfo::HB::price': 関数呼び出しには引数リストがありません。メンバへのポインタを作成するために '&iteminfo::HB::price' を使用してください
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\KVS.h(41) : error C2440: '=' : '' から 'overloaded-function' に変換できません。
1>test.cpp
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C2146: 構文エラー : ';' が、識別子 'itemname' の前に必要です。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(7) : error C2864: 'iteminfo::HB::itemname' : スタティック const 整数データ メンバ以外をクラス内で初期化することはできません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(8) : error C2864: 'iteminfo::HB::price' : スタティック const 整数データ メンバ以外をクラス内で初期化することはできません
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(10) : error C2059: 構文エラー : '}'
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(10) : error C2143: 構文エラー : ';' が '}' の前にありません。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\iteminfo.h(10) : error C2238: ';' の前に無効なトークンがあります。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\KVS.h(41) : error C2597: 静的でないメンバ 'iteminfo::HB::price' への参照が正しくありません。
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\KVS.h(41) : error C3867: 'iteminfo::HB::price': 関数呼び出しには引数リストがありません。メンバへのポインタを作成するために '&iteminfo::HB::price' を使用してください
1>d:\documents and settings\ti\my documents\visual studio 2005\projects\test\test\KVS.h(41) : error C2440: '=' : '' から 'overloaded-function' に変換できません。
>ookamiさん
VC++でformプログラミングでプロジェクトを作成しました
kvs.hにある
void setitemname(string name,int cnt)で
どこからでも使えるようにしたいです