누군가이 세그먼트를 실행하는 이유를 말해 줄 수 있습니까? 내가 시도하고 개체 배열의 배열에 대한 포인터, 어떻게이 문제를 해결할 수 있습니까? sf :: Vector2 클래스의 선언은 다음에서 찾을 수 있습니다. http://www.sfml-dev.org/documentation/1.6/classsf_1_1Vector2.php포인터를 통해 객체 배열의 배열을 인덱싱 할 때 세그먼트 오류 발생
많은 감사.
#include <SFML/System/Vector2.hpp>
#include <iostream>
class Tet
{
public:
Tet();
private:
static sf::Vector2 <int> I[4];
static sf::Vector2 <int> J[4];
static sf::Vector2 <int> *types[2];
};
sf::Vector2 <int> Tet::I[4] = {sf::Vector2 <int>(0,1),
sf::Vector2 <int>(1,1),
sf::Vector2 <int>(2,1),
sf::Vector2 <int>(3,1)};
sf::Vector2 <int> Tet::J[4] = {sf::Vector2 <int>(1,1),
sf::Vector2 <int>(2,1),
sf::Vector2 <int>(3,1),
sf::Vector2 <int>(3,2)};
sf::Vector2 <int>* Tet::types[2] = { I,J };
Tet::Tet()
{
//trying to print out x member of first vector of I
std::cout << (*(*(types))).x << std::endl;
}
main()
{
Tet t = Tet();
}
편집 : g ++ 컴파일러
김포 :: Vector2 및 방법이 어떻게 구현되어 함께 초기화? 코드를 보면 코드가 제대로 작동한다고 가정합니다. sf :: Vector2에 대한 액세스가 없으면 아무도이 문제를 해결할 수 없으므로 더 널리 사용 가능한 유형으로 이것을 재현 할 수 있습니까? – Chad
예상대로 간단한 예제 (sf :: Vector2을 char로 대체)가 작동하는 것 같습니다. –
Chad
정의 됨 http://www.sfml-dev.org/documentation/1.6/Vector2_8hpp_source.php – aultbot