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;
}
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;
}
相关文章推荐
- error C2552: 'ivec' : non-aggregates cannot be initialized with initializer list
- non-aggregates cannot be initialized with initializer list
- non-aggregates cannot be initialized with initializer list
- The type List is not generic; it cannot be parameterized with arguments
- The type List is not generic; it cannot be parameterized with arguments***
- The type List is not generic; it cannot be parameterized with arguments
- The type List is not generic; it cannot be parameterized with arguments<T>
- The type List is not generic; it cannot be parameterized with arguments <Integer>
- The type List is not generic; it cannot be parameterized with arguments
- pyinstaller打包paramiko后,运行出错“Multibackend cannot be initialized with no backends”解决
- UICollectionView must be initialized with a non-nil layout parameter
- iOS-UI之UICollectionView must be initialized with a non-nil layout parameter'解决方式
- 创建UICollectionView时出错UICollectionView must be initialized with a non-nil layout parameter
- Swift 关联Storyboard中的controller解决UICollectionView must be initialized with a non-nil layout parameter
- The type List is not generic; it cannot be parameterized with arguments
- UICollectionView must be initialized with a non-nil layout parameter
- 创建UICollectionView时出错UICollectionView must be initialized with a non-nil layout parameter
- the type List is not generic; it cannot be parameterized with arguments<T>解决办法
- must be initialized in constructor base/member initializer list
- A project with an Output Type of Class Library cannot be started directly