中易网

errorc2059:syntaxerror:'...'是什么意思

答案:2  悬赏:80  
解决时间 2021-01-19 22:53
errorc2059:syntaxerror:'...'是什么意思
最佳答案
Compiler Error C2059
Error Message
syntax error : 'token'
The token caused a syntax error.
To
determine the cause, examine not only the line listed in the error
message, but also the lines above it. The following example generates an
error message for the line declaring j, but the true source of the error appears on the line just above it.
If
examining the lines yields no clue to what the problem might be, try
commenting out the line listed in the error message and possibly several
lines above it.
If the error message occurs on a symbol immediately following a typedef variable, check that the variable is defined in the source code.
You may get C2059 if a symbol evaluates to nothing, as can occur when you compile with /Dsymbol=.












// C2059a.cpp
// compile with: /DTEST=
#include <stdio.h>

int main() {
#ifdef TEST
printf_s("\nTEST defined %d", TEST); // C2059
#else
printf_s("\nTEST not defined");
#endif
}





Another specific reason you can get C2059 is when you compile an
application that specifies a structure in the default arguments for a
function. The default value for an argument must be an expression. An
initializer list, such as that used to initialize a structure, is not an
expression. The resolution is to define a constructor to perform the
required initialization.
The following example generates C2059:












// C2059b.cpp
// compile with: /c
struct ag_type {
int a;
float b;
// Uncomment the following line to resolve.
// ag_type(int aa, float bb) : a(aa), b(bb) {}
};

void func(ag_type arg = {5, 7.0}); // C2059
void func(ag_type arg = ag_type(5, 7.0)); // OK





You can also get C2059 if you define a member template class or
function outside the class. See Knowledge Base article Q241949 for more
information.
C2059 can occur for an ill-formed cast.
The following sample generates C2059:












// C2059c.cpp
// compile with: /clr
using namespace System;
ref class From {};
ref class To : public From {};

int main() {
From^ refbase = gcnew To();
To^ refTo = safe_cast<To^>(From^); // C2059
To^ refTo2 = safe_cast<To^>(refbase); // OK
}





C2059 can also occur if you attempt to create a namespace name that contains a period.
The following sample generates C2059:












// C2059d.cpp
// compile with: /c
namespace A.B {} // C2059

// OK
namespace A {
namespace B {}
}





C2059 can also occur if you define a member template class or function outside the class.
全部回答
請追問
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
2014年信鸽足环766211是那的
爱国者F907W19寸液晶显示器像素是多少?
flnest是什么意思?
“节物风光不相待,桑田碧海须臾改”是什么意
pu笔袋弄上水性笔油怎么办
归根到底终须离猜一肖
一般男生追你多久你才会答应交往
从北京运至天津63吨货物,如果用载重5吨的大
8090组合最后的成员确定了么、都有谁、
长须鲸的外形特征
卡片机是傻瓜照相机
常若有过 旁若有人 是什么意思
五一桥社区居委会地址好找么,我有些事要过去
玩cf玩的好好的突然人物自己往一边走,嗯啥也
乌鲁木齐最大边境贸易市场叫什么名字
推荐资讯
名流音乐会所地址在什么地方,我要处理点事
手q卡bug发红包消失,我输入了支付宝密码并且
求《从此生活有了趣味》作文600字,多发两篇
苹果8有苹果6p大没有
CAD的3D图如何用UG能打开
psv 最终幻想X-2怎么保存游戏进度
三相电表60A是指每相吗
求马桶清洁剂配方
三星w579内屏多少钱
如何推销钢结构
首尔购物的地方?
2.5岁不到幼儿第一次接种霍乱口服疫苗后幼儿
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?