-var-创建;无法创建可变对象

发布于 2025-01-30 05:08:54 字数 538 浏览 3 评论 0原文

我已经尝试制作一个两个包含对象数组的2个对象,两者都是由同一构造函数创建的,但是当我调试一个对象时,一个会得到一个adress,另一个是null。

Player::Player(std::string name) {
    this->name = name;
    p.setSize(7);
}

那就是带有数组的对象。

Pile::Pile(int size) {
    stoneArr = new Stone[size];
    this->size = size;
}

Pile::Pile(){

}

那就是播放器内部的对象,由数组组成。

编辑: https://i.sstatic.net/hr1zy.jpg

两者都是无效的,如果您需要更多信息,请让我知道我不介意上传整个项目...

i've trying to make an 2 object which both contains an object array , both are created from the same constructor but when i debug one gets an adress and the other is NULL.

Player::Player(std::string name) {
    this->name = name;
    p.setSize(7);
}

thats the object with the array.

Pile::Pile(int size) {
    stoneArr = new Stone[size];
    this->size = size;
}

Pile::Pile(){

}

thats the object inside of player which consists of an array.

EDIT:
https://i.sstatic.net/Hr1ZY.jpg

when i deleted the game instance, both are null, if you need like further info let me know i dont mind upload the whole project...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文