개체의 인스턴스 생성 중에 개체의 2D 벡터 만들기와 관련하여 질문이 있습니다."복사 된 생성자에 대해"삭제 된 함수를 참조하려고합니다. "CC248" 'operator ='클래스에 선언 된 전용 멤버에 액세스 할 수 없습니다. '(Cocos2dx)
배경 : 나는 Tile 개체의 2D 벡터가 필요한 Dungeon이라는 클래스가 있습니다. (벡터 나는 인스턴스화 때까지이 벡터의 크기를 알 수 없기 때문에 크기를 조정할 수 있기 때문입니다.)
오류 :
Error C2280 'Tile &Tile::operator =(const Tile &)': attempting to reference a deleted function MyCppGame c:\users\dante\git\yshacpp\mycppgame\classes\tile.cpp 18
업데이트 : 지금은 수신하고 Error C2248 'cocos2d::Sprite::operator =': cannot access private member declared in class 'cocos2d::Sprite'
-가 될 수있는 Sprite의 operator=
과 함께 cocos2D-X 문제가 있습니까? 도움이되지 않았다 public
에 스프라이트 선언 퍼팅하지만 난
내 의혹 (수정) ...적인 Cocos2D-X 뭔가를 의심 해요 : 내 Tile
클래스 내부cocos2d::Sprite* floor, item, overlay, ceiling;
보이는이 오류가 throw 할 수 있습니다.
내가 시도한 것 : 타일을위한 자체 생성자 생성.
은 어쩌면 나의 의심은 잘못이지만, 사람이 할 수 있다면 이것이 내가 감사하게 될 거라고 일이 왜 나를 알아! 클래스의
CPP 파일 (타일) 클래스 타일의
#include "Tile.h"
Tile::Tile() : block(false), hasCharacter(false) { /* Nothing */ }
헤더 파일은
#ifndef __TILE_H__
#define __TILE_H__
#include ...
class Tile {
protected:
bool deepCopy(const Tile& copyTile) {
bool result = false;
if (©Tile != this) {
this->character = copyTile.character;
this->floor = copyTile.floor;
this->item = copyTile.item;
this->overlay = copyTile.overlay;
this->ceiling = copyTile.ceiling;
result = true;
}
return result;
}
cocos2d::Sprite* floor, item, overlay, ceiling;
// private: // nothing atm
public:
bool block, hasCharacter;
Character character;
Tile();
Tile(const Tile& copyTile) { deepCopy(copyTile); };
Tile& operator=(const Tile& copyTile) { deepCopy(copyTile); return *this; }
//~Tile();
};
#endif // __TILE_H__
벡터는 개체를 복사하거나 이동해야하므로 복사 할 수없는 이동 불가능 개체의 벡터를 사용할 수 없습니다. – immibis
'operator ='는 복사 연산자가 아니라 대입 연산자입니다 –
'문자 '는 복사 할 수 없으므로'Tile'의 암시 적 대입 연산자가 삭제됩니다 –