weixin_43409736 2018-10-28 09:23 采纳率: 60%
浏览 1003
已采纳

'typedef ' : ignored on left of 'class CStringList' when no variable is declared

//CListTest.cpp:Define the entry point for the console application
//#include"stdafx.h"
#include
#include
#include

using namespace std;

typedef CStringListStringList;
//实现一个以String为元素的数组类
//入参和出参都是一个指向string的指针
int main()//(int argc,_TCHAR* argv[])
{
const CString str[]={
_T("1st Score"),
_T("2nd Score"),
_T("3rd Score"),
_T("4th Score"),
};
CStringList list1;
size_t i=0;
//从链表头部向链表中添加记录
for(i=0;i<sizeof(str)/sizeof(CString);i++)
{
list1.AddHead(str[i]);
}

CString string;
while(!list1.IsEmpty())
{
string=list1.RemoveHead();
wcout<<LPCTSTR(string)<<endl;
//最好每次清空string
string.ReleaseBuffer();
}
cout<<endl;
return 0;
}
//程序代码如上,本来预计应输出:
/*4th Score
3rd Score
2nd Score
1st Score*/
// 但却显示错误为:
//D:\Visual C++ Project\CList_P96\CList.cpp(9) : warning C4091: 'typedef ' : ignored on left of 'class CStringList' when no variable is declared
//D:\Visual C++ Project\CList_P96\CList.cpp(9) : error C2143: syntax error : missing ';' before '<'
//D:\Visual C++ Project\CList_P96\CList.cpp(9) : error C2143: syntax error : missing ';' before '<'

  • 写回答

2条回答 默认 最新

  • threenewbee 2018-10-28 16:50
    关注

    你是不是没有添加对mfc的支持

    我这里编译正常(唯一的修改typedef CStringList StringList;少空格,不知道是你没有写还是csdn的bug)

    图片说明

    还有,下次贴代码,请使用编辑器上</>的按钮格式化下,你这么贴代码不完整你没有发现么?

    问题如果解决,请点我回答右边的采纳,谢谢

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记