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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题