这是我的代码:
#pragma once
#include "Card.h"
class Foundation {
Card* cards[13];
int current;
char suit;
friend ostream& operator<< (ostream& os, Foundation& f);
public:
Foundation(char suit = 'H');
bool isPlacable(Card* c);
void put(Card* c);
bool isFull();
void clear();
};
/* Warning C26495 Variable 'Foundation::cards' is uninitialized. Always initialize a member variable (type.6) below. */
Foundation::Foundation(char suit) {
this->suit = suit;
}
有什么问题吗?
发布于 2021-07-11 06:26:46
您会得到警告,因为您没有初始化构造函数中的成员或使用初始化程序列表。
这可能会修正您的警告:
class Foundation {
Card* cards[13] = {};
int current;
char suit;
friend ostream& operator<< (ostream& os, Foundation& f);
public:
Foundation(char suit = 'H');
bool isPlacable(Card* c);
void put(Card* c);
bool isFull();
void clear();
};
https://stackoverflow.com/questions/68333673
复制相似问题