您的位置:首页 > 其它

Compiler Error C2552 non-aggregates cannot be initialized with initializer list

2009-05-04 10:17 274 查看
Compiler Error C2552 non-aggregates cannot be initialized with initializer list. This error beacuse of the following.....

The specified identifier was incorrectly initialized.

An initializer list is needed to initialize the following types:

1) An array

2) A class, structure, or union that does not have constructors, private or protected members, base classes, or virtual functions

These types are known as “aggregates.”

sample code....

Code

// CLR.cpp : main project file.

#include "stdafx.h"

#define _AFXDLL

#include "AFX.h"

#include <strsafe.h>

#include <iostream>

using namespace std;

using namespace System;

using namespace System::Diagnostics;

typedef struct _MYOVERLAPPED:public OVERLAPPED{

int i;

}MYOVERLAPPED, *PMYOVERLAPPED;

int main(array<System::String ^> ^args){

MYOVERLAPPED my = {0}; // my has base class, so this line will generate Compiler Error C2552

cout << my.i << endl;

system("pause");

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐