首页 新闻 会员 周边

new struct[]

0
悬赏园豆:5 [已解决问题] 解决于 2011-10-14 12:51
有这样一个结构体:
typedef struct MineField 
{
BOOL isMine; //1 is mine,0 is not mine, -1 unknown.
int nearByNum; // the number of this grid's around.
MineField()
{
isMine = -1;
nearByNum = 0;
}
} MINEFIELD, *LPMINEFIELD;
int main(){
int  count = 10;
struct MINEFIELD* pMineField;
pMineField = new strucy MINEFIELD[count];
}
请问大家我这样写有哪里不对呢?为什么我编译时说“no appropriate default constructor available!”呢?
my-sky的主页 my-sky | 初学一级 | 园豆:94
提问于:2011-10-12 09:03
< >
分享
最佳答案
1
typedef的语法使用问题,如下两个形式可选:
MINEFIELD* pMineField;
pMineField = new MINEFIELD[count];

struct MineField*  s;
s= new MineField[10];
收获园豆:5
2012 | 高人七级 |园豆:21230 | 2011-10-12 11:10

多谢!

my-sky | 园豆:94 (初学一级) | 2011-10-14 12:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册