typedef语法错误 [英] typedef Syntax Error

查看:106
本文介绍了typedef语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在typedef上遇到语法错误代码行在这里。任何

想法为什么? TIA

struct CSTYPE

{//城市/州记录

string csKey; //城市/州钥匙

string csCity; // City

string csState; //国家代码

};

typedef map< string,CSTYPECSINFO; //< ===错误在这里

extern CSINFO cityStInfo;

extern map< string,CSTYPE> :: iterator csIter;

extern CSTYPE workCS;

I''m getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA
struct CSTYPE
{ // City/State Record
string csKey; // City/State "Key"
string csCity; // City
string csState; // State Code
};
typedef map<string, CSTYPECSINFO; // <=== error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;

推荐答案

10月31日,2:01 * pm,mrc2 ... @ cox.net(Mike Copeland)写道:
On Oct 31, 2:01*pm, mrc2...@cox.net (Mike Copeland) wrote:

* *我在typedef上遇到语法错误代码行在这里。 *任何

想法为什么? * TIA


struct CSTYPE

{* * * * * * * * * * * * * * * * * ** * * * * //城市/州记录

* * * * string csKey; * * * * * * * * * * ** * * //城市/州钥匙

* * * * string csCity; * * * * * * * * * * * * * * * * * * * //城市

* * * * string csState; * * * * * * * * * * * * * * * * //状态代码};


typedef map< string,CSTYPECSINFO; * //< ===错误在这里

* * * * extern CSINFO cityStInfo;

* * * * extern map< string,CSTYPE> :: iterator csIter;

* * * * extern CSTYPE workCS;
* *I''m getting a syntax error on the "typedef" code line here. *Any
thoughts on why? *TIA

struct CSTYPE
{ * * * * * * * * * * * * * * * * * ** * * * *// City/State Record
* * * * string csKey; * * * * * * * * * * ** * *// City/State "Key"
* * * * string csCity; * * * * * * * * * * * * * * * * * * * // City
* * * * string csState; * * * * * * * * * * * * * * * *// State Code};

typedef map<string, CSTYPECSINFO; *// <=== error here
* * * * extern CSINFO cityStInfo;
* * * * extern map<string, CSTYPE>::iterator csIter;
* * * * extern CSTYPE workCS;



1.你是#include< mapand< string>?

2. map和string live in std :: namespace

3.您是否愿意描述具体的错误?


1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?


red floyd写道:
red floyd wrote:

10月31日下午2:01,mrc2 ... @ cox.net(Mike Copeland)写道:
On Oct 31, 2:01 pm, mrc2...@cox.net (Mike Copeland) wrote:

>我在typedef上遇到语法错误代码行在这里。对于为什么有任何想法? TIA

struct CSTYPE
{//城市/州记录
string csKey; //城市/州密钥
字符串csCity; // City
string csState; // State Code};

typedef map< string,CSTYPECSINFO; //< ===错误在这里
extern CSINFO cityStInfo;
extern map< string,CSTYPE> :: iterator csIter;
extern CSTYPE workCS;
> I''m getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE
{ // City/State Record
string csKey; // City/State "Key"
string csCity; // City
string csState; // State Code};

typedef map<string, CSTYPECSINFO; // <=== error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;




1.你是#include< mapand< string>?

2. map和string live in the std :: namespace

3.您是否愿意描述具体的错误?



1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?



他的编译器可能不允许使用不完整的

类型作为模板参数,即使在typedef中也是如此,' 'CSTYPE''

当时不完整...


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要问

It''s possible that his compiler does not allow the use of incomplete
types as template arguments, even in typedefs, and ''CSTYPE'' is
incomplete at that point...

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


Mike Copeland写道:
Mike Copeland wrote:

我在typedef上遇到语法错误代码行在这里。
I''m getting a syntax error on the "typedef" code line here.



....


以下似乎与GCC 4一样有效。


#include< map>

#include< string>


使用std :: map;

使用std :: string;


// TODO:展开" cs"更有意义的事情。

命名空间cs {


// TODO:给这个类型一个更有意义的名字。

结构类型{

string key;

string city;

string state;

};


typedef map< string,typeinfo;

}


#include< iostream>


int main(){


cs :: info info;


info [" hello"]。key =" world" ;;

info [" foo"]。key =" bar";


std :: cout<< info [" hello"]。key<< ''\ n'';

std :: cout<< info [" foo"]。key<< ''\ n'';

}

....

The following appears to work as expected w/GCC 4.

#include <map>
#include <string>

using std::map;
using std::string;

// TODO: Expand "cs" to something more meaningful.
namespace cs {

// TODO: Give this type a more meaningful name.
struct type {
string key;
string city;
string state;
};

typedef map<string, typeinfo;
}

#include <iostream>

int main() {

cs::info info;

info["hello"].key = "world";
info["foo"].key = "bar";

std::cout << info["hello"].key << ''\n'';
std::cout << info["foo"].key << ''\n'';
}


这篇关于typedef语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆