C++ 我的card类不断收到编译器错误c1001

C++ 我的card类不断收到编译器错误c1001,c++,C++,这是标题 #ifndef CARD_H #define CARD_H #include <iostream> #include <ios> #include <string> using namespace std; class Card { friend class deck; friend class Hand; private: // assigns ranks to a string to greatly shorten the necessary

这是标题

#ifndef CARD_H
#define CARD_H
#include <iostream>
#include <ios>
#include <string>

using namespace std;
class Card {
friend class deck;
friend class Hand;
private:

// assigns ranks to a string to greatly shorten the necessary array
const string ourRanks[13] = { "2", "3", "4",
    "5", "6", "7", "8", "9", "10", "Jack",
    "Queen", "King", "Ace" };

//  assigns suits to a string to greatly shorten the necessary array
const string ourSuits[5] = { "Clubs", "Diamonds", "Hearts", "Spades" };


// stores the rank
int rank;

// stores the suit
int suit;

// card, stores string card for usage
string card;


public:


Card() {
    this -> rank = 0;
    this -> suit = 0;
    this -> card = "The Two of clubs";
    return;
}


// Card constructor
Card(int ranks, int suits);


// gets rank and suit
int getRank(int ranks);
int getSuit(int suits);


// defines the value
int getValue();


// gets the highest and lowest values
int getHighValue();
int getLowValue();


// finds and declares the rank and suit
bool validRank(int ranks);
bool validSuit(int suits);


// creates a card

 bool equals();


// exports the card to be used
string newCard();

// These create the numerical representation of the card ranks
const int TWO = 0;
const int THREE = 1;
const int FOUR = 2;
const int FIVE = 3;
const int SIX = 4;
const int SEVEN = 5;
const int EIGHT = 6;
const int NINE = 7;
const int TEN = 8;
const int JACK = 9;
const int QUEEN = 10;
const int KING = 11;
const int ACE = 12;


// These create the numerical representation of the card suits
const int CLUB = 0;
const int DIAMONDS = 1;
const int HEARTS = 2;
const int SPADES = 3;

 };

  #endif

很抱歉浪费您的时间,我已经解决了问题,它现在可以正常工作了,我曾经对我的数组进行过多次初始化,我通过重新调整它的参数来修复它,这是一个编译器错误。我在VS2015中尝试了相同的代码,收到了以下消息:

1>------ Rebuild All started: Project: scratch, Configuration: Debug Win32 ------
1>  scratch.cpp
1>E:\Code\VS2015\scratch\scratch\scratch.cpp : fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++
1>   Help menu, or open the Technical Support help file for more information
1>
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
正如Patrick Duggin在回答和评论中指出的,它与数组初始化有关。我的最小可重复性如下:

#include <string>

class X
{
    std::string strings[2] = { "first" };
};

int main()
{
    X x;
}
#包括
X类
{
std::string strings[2]={“first”};
};
int main()
{
X;
}
上面的代码产生相同的错误。这是一个有效的C++代码。调整数组大小,或者向数组中添加另一个初始值设定项是解决此错误的方法


我无法使用不同类型的数组重现该错误。C++的C++版本C++,11,C++,14,C++ 17,C++ 93,你是指微软VisualStudio版本X.x,因为在这种情况下,我的意思是C++迭代。这些都是ISO标准化的,你知道我的意思吗?例如,在标准化之前,它们被称为C++0x、C++1y或C++1z。但是我想利用你提供的信息,我可以自己找到答案。等等,你是说编译器版本吗,我刚刚通过命令提示符运行了一个工作文件,上面说优化编译器版本19.0
1>------ Rebuild All started: Project: scratch, Configuration: Debug Win32 ------
1>  scratch.cpp
1>E:\Code\VS2015\scratch\scratch\scratch.cpp : fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++
1>   Help menu, or open the Technical Support help file for more information
1>
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
#include <string>

class X
{
    std::string strings[2] = { "first" };
};

int main()
{
    X x;
}