开发学院手机开发Symbian 开发 Symbian 中的动态数组 CArrayX 阅读

Symbian 中的动态数组 CArrayX

 2010-08-31 00:12:00 来源:WEB开发网   
核心提示:console->Printf(_L("Press any key to continue"));console->Getch();//以姓名方式查找console->Printf(_L("Find student by name"));//建立主键,对于不同类

console->Printf(_L("Press any key to continue "));

console->Getch();

//以姓名方式查找

console->Printf(_L("Find student by name "));

//建立主键,对于不同类型的CArray有不同的主键类型

//_FOFF(c,f)宏来取得类中字段的偏移量

TKeyArrayFix nameKey(_FOFF(TStudent,iSName), ECmpNormal);

TInt findPos;

TStudent S(StuName1,0,0);

console->Getch();

if(StuArrayFlat->Find(S, nameKey, findPos) != KErrNotFound)

{

//查找对象是S,按ECmpNormal格式

console->Printf(_L("findPos is %d "),findPos);

console->Printf((*StuArrayFlat)[findPos].iSName);//直接引用findPos的值,有的书上写findPos-1,这是错误的!

}

console->Printf(KRETURN);

console->Printf(_L("Press any key to continue "));

console->Getch();

//以成绩方式排序

TKeyArrayFix scoreKey(_FOFF(TStudent,iScore), ECmpTInt32);

User::LeaveIfError(StuArrayFlat->Sort(scoreKey));

for(i=0;iCount();i++)

{

console->Printf(_L("name is "));

console->Printf((*StuArrayFlat)[i].iSName);

console->Printf(KRETURN);

console->Printf(KFORMAT2,(*StuArrayFlat)[i].iSNo);

console->Printf(KRETURN);

console->Printf(KFORMAT3,(*StuArrayFlat)[i].iScore);

console->Printf(KRETURN);

}

CleanupStack::PopAndDestroy();

}

上一页  1 2 3 4 

Tags:Symbian 动态 数组

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接