显式调用构造函数

#include "stdafx.h"
#include 
using namespace std;
int i=1;
/*数组构造*/
class testv1
{
public:
	int v1;
	testv1() {v1=i++;}

};
int _tmain(int argc, _TCHAR* argv[])
{
#define ARRAY_SIZE 10
	//testv1 test_array[ARRAY_SIZE];//定义数组时自动调用构造函数,与JAVA不同
	testv1 *test_array = new testv1[ARRAY_SIZE]();
	for(int i=0;i

显式调用构造函数_第1张图片
 
 

你可能感兴趣的:(VC)