C++ 列挙型

#include <iostream>
using namespace std;

//列挙型
enum WEAPON_TYPE
{
LargeS
HeavyyBowgun
};

struct HUNTER
{
int money;
int rank;
char name[32];
};

int main()
{
//int型のサイズを画面に表示する
cout << sizeof(int) << endl;

//unsigned short型のサイズ(ばいと数)を画面に表示する
cout << sizeof(unsigned short) << endl;

//double型のサイズを画面に表示する
cout << sizeof(double) << endl;

//HUNTER型のサイズを画面に表示する
cout << sizeof(HUNTER) << endl;

//変数dのサイズを画面に表示する
double d;
cout << sizeof(d) << endl;

//配列aのサイズを画面に表示する
int a[3];
cout << sizeof(a) << endl;
cout << sizeof(a[0]) << endl;

//構造体内部のメンバ変数のサイズを画面に表示する
cout << sizeof(HUNTER::name) << endl;

//文字列”Hello”のサイズを画面に表示する
cout << sizeof(“Hello”) << endl;

//文字列”Hello”が格納された配列textのサイズを画面に表示する
char text[32] = “hello”;
cout << sizeof(text) << endl;

//関数mainのサイズを画面に表示する
cout << sizeof(1 + 1) << endl;

//整数値(int) + 小数double型 = (小数(double)
cout << sizeof(1 + 1.0) << endl;

//列挙型のサイズを画面に表示する
cout << sizeof(WEAPON_TYPE) << endl;

//char型の変数の値の範囲は -128 +127
char c;
c = 129;
cout << (int)c << endl;

short s;
s = 32768;
cout << s << endl;

//64bit整数型
__int64 i;
cout << sizeof(i) << endl;
return 0;
}
//ダメージ計算関数
int damage(攻撃者の情報 対象者の情報)
{
return ダメージ
}

Itemtype DropItem(倒した敵の情報)

{

switch (倒した敵 DropID)
{
case 0;
return
}
return Itemtype::
}
戻りの型 関数名(引数の型 引数名 引数名、・・・)
{
ここで何かの処理

return 結果;
}

投稿者: chosuke

趣味はゲームやアニメや漫画などです

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です