本文介绍了我不明白这一点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我不明白这一点:



i有一个变量:



PULONG尝试;



为什么在我学习的代码中,我发现了这样的东西? :



试试[2]



i不明白因为PULONG不是和阵列。



谢谢

Hi i dont understand this :

i have one variable :

PULONG try;

why in the code that im studing, i found something like this? :

try[2]

i dont understand becuause PULONG isnt and array.

Thanks

推荐答案

List<String^>^ dinosaurs = gcnew List<String^>();
dinosaurs->Add("Tyrannosaurus");
dinosaurs->Add("Amargasaurus");
dinosaurs->Add("Mamenchisaurus");
dinosaurs->Add("Deinonychus");
dinosaurs->Add("Compsognathus");
for each(String^ dinosaur in dinosaurs )
{
    Console::WriteLine(dinosaur);
}
Console::WriteLine("\ndinosaurs[3]: {0}", dinosaurs[3]);

(取自MSDN示例: [])



因此,如果您的类派生自支持索引器的类,或实现索引器运算符

operator [] 然后完全允许索引。

(Taken from MSDN example: http://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-3[^])

So if your class is derived from a class that supports indexers, or implements the indexer operator
operator[] then indexes are perfectly allowed.


typedef unsigned long * PULONG;



那么你可以写一下,例如


Then you may write, for instance

PULONG try = malloc(100*sizeof(unsigned long));
if ( ! try ) { /* handle error */}
try[2] = 5;
//...

free(try);





编译器不会抱怨。



And the compiler won't complain.



这篇关于我不明白这一点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-30 05:17