2011-02-09 205 views
0
unsigned __int8 result[]= new unsigned __int8[sizeof(username) * 4]; 

智能感知:初始化与 '{...}' 预期聚合对象这里有什么问题

+3

你有一个[C++书](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)你从中学习? – GManNickG 2011-02-09 11:15:53

+0

@GMan nope,加上如果我想返回结果怎么办? – TQCopier 2011-02-09 11:25:38

回答

0
unsigned __int8 *result = new unsigned __int8[sizeof(username) * 4]; 
1

的类型是不一样的;你不能用指针初始化数组。

new unsigned __int8[sizeof(username) * 4];返回unsigned __int8*,不unsigned __int8[]

改变你的代码

unsigned __int8* result = new unsigned __int8[sizeof(username) * 4]; 
0

新返回一个指针,而不是一个数组。你应该声明

unsigned __int8* result = .... 
0

这里,result是一个__int8的数组,所以你不能给整个数组赋值一个值。你真的想要:

unsigned __int8* p_result = new unsigned __int8[sizeof username * 4]; 
相关问题