最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

誰能幫幫我看看這個c++《我的世界》簡易版程序錯哪里了?

2023-08-20 22:22 作者:克利莫夫斯基  | 我要投稿

代碼如下,使用程序是GUIDE

#include <iostream>

#include<cstdio>

#include<cmath>


using namespace std;


// 定義方塊的類型

enum BlockType {

? ? AIR, GRASS, DIRT, STONE, WATER, LAVA

};


// 定義方塊對象

struct Block {

? ? BlockType type;


? ? Block(BlockType bType) {

? ? ? ? type = bType;

? ? }

};


// 定義玩家對象

struct Player {

? ? int x;

? ? int y;

? ? int z;


? ? Player() {

? ? ? ? x = y = z = 0;

? ? }

};


// 創(chuàng)建一個地圖對象

?Block world[10][10][10];


// 初始化地圖

void initWorld() {

? ? for (int i = 0; i < 10; i++) {

? ? ? ? for (int j = 0; j < 10; j++) {

? ? ? ? ? ? for (int k = 0; k < 10; k++) {

? ? ? ? ? ? ? ? if (i == 0 || i == 9 || j == 0 || j == 9 || k == 0 || k == 9) {

? ? ? ? ? ? ? ? ? ? // 邊界設(shè)置為石頭方塊

? ? ? ? ? ? ? ? ? ? world[i][j][k] = Block(STONE);

? ? ? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? ? ? // 其他位置設(shè)置為空氣方塊

? ? ? ? ? ? ? ? ? ? world[i][j][k] = Block(AIR);

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? }

? ? }

}


// 在指定位置放置方塊

void placeBlock(int x, int y, int z, BlockType type) {

? ? world[x][y][z] = Block(type);

}


// 打印當(dāng)前玩家和周圍方塊信息

void printPlayerInfo(Player player) {

? ? cout << "玩家位置: (" << player.x << ", " << player.y << ", " << player.z << ")" << endl;

? ? cout << "玩家周圍方塊信息:" << endl;

? ? for (int i = -1; i <= 1; i++) {

? ? ? ? for (int j = -1; j <= 1; j++) {

? ? ? ? ? ? for (int k = -1; k <= 1; k++) {

? ? ? ? ? ? ? ? int x = player.x + i;

? ? ? ? ? ? ? ? int y = player.y + j;

? ? ? ? ? ? ? ? int z = player.z + k;


? ? ? ? ? ? ? ? if (x >= 0 && x < 10 && y >= 0 && y < 10 && z >= 0 && z < 10) {

? ? ? ? ? ? ? ? ? ? BlockType type = world[x][y][z].type;

? ? ? ? ? ? ? ? ? ? cout << "(" << x << ", " << y << ", " << z << "): " << type << endl;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? }

? ? }

}


int main() {

? ? Player player;


? ? // 初始化地圖

? ? initWorld();


? ? // 打印玩家初始信息

? ? printPlayerInfo(player);


? ? // 在(1, 1, 1)處放置草地方塊

? ? placeBlock(1, 1, 1, GRASS);


? ? // 移動玩家位置到(3, 3, 3)

? ? player.x = 3;

? ? player.y = 3;

? ? player.z = 3;


? ? // 打印移動后玩家信息

? ? printPlayerInfo(player);


? ? return 0;

}

錯誤顯示:

MC.cpp:30: error: no matching function for call to `Block::Block()

翻譯過來就是:MC.cpp:30:錯誤:調(diào)用Block::Block()沒有匹配的函數(shù)(第三十行的block錯誤)

有誰懂的幫我看看唄


誰能幫幫我看看這個c++《我的世界》簡易版程序錯哪里了?的評論 (共 條)

分享到微博請遵守國家法律
酒泉市| 林州市| 丰台区| 七台河市| 武定县| 庆安县| 和田县| 特克斯县| 两当县| 临潭县| 自贡市| 榆中县| 调兵山市| 武山县| 文成县| 琼结县| 湖州市| 响水县| 高唐县| 松原市| 申扎县| 通化县| 余庆县| 宿州市| 阳新县| 健康| 古丈县| 绍兴市| 清丰县| 阿瓦提县| 达孜县| 平塘县| 包头市| 恩施市| 伊宁市| 峨眉山市| 九台市| 高碑店市| 永丰县| 喀什市| 开封市|