玩名称空间...... [英] playing with namespaces...

查看:64
本文介绍了玩名称空间......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




由于

一些冲突,我有一组函数被封装到命名空间中。


// XYZ.h

// ------

名称空间CC

{

void foo();

double dfoo = 0;

}


// XYZ.cpp

// --------

命名空间CC

{

void foo(){dfoo = 1; }

}


使用namepsace CC;

int APIENTRY WinMAIN(..)

{

dfoo = 2;

foo();

}


没有命名空间一切都是好的,但现在我的GCC说:


... \lib / libc.a(winmain.o)(。text + 0x14):对'main''的未定义引用br />

你能帮忙吗?

-

-Gernot

int main(int argc,char ** argv){printf

("%silto%c%cf%cgl%ssic%ccom%c"," ma",58,''g'',64," ba,46,10);}


________________________________ ________

寻找一款好游戏?亲自动手吧!

GLBasic - 你可以这样做
www.GLBasic .com

解决方案



" Gernot Frisch" < Me@Privacy.net>在消息中写道

新闻:2n ************ @ uni-berlin.de ...



使用namepsace CC;




查看命名空间的拼写。


-Sharad


> >使用namepsace CC;


查看命名空间的拼写。



是的,确定 - 但那不是它。我只是快速点击这里进行演示

目的......




" Gernot Frisch" < Me@Privacy.net>在消息中写道

news:2n ************ @ uni-berlin.de ...

使用namepsace CC;



查看命名空间的拼写。


是的,确定 - 但那不是吗。我只是在这里快速输入它用于演示
目的......




然后你的问题就在别的地方。这对我来说很好用g ++

3.3.1。


名称空间CC

{

void foo();

double dfoo = 0;

}


命名空间CC

{

void foo(){dfoo = 1;}

}


使用名称空间CC;

int main()

{

dfoo = 2;

foo();

}


Hi,

I have a set of functions that I enclousured into a namespace due to
some conflicts.

// XYZ.h
//------
namespace CC
{
void foo();
double dfoo=0;
}

// XYZ.cpp
//--------
namespace CC
{
void foo() {dfoo=1;}
}

using namepsace CC;
int APIENTRY WinMAIN(..)
{
dfoo = 2;
foo();
}

without the namespace everything was OK, but now my GCC says:

...\lib/libc.a(winmain.o)(.text+0x14): undefined reference to `main''

Can you help?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, ''g'', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com

解决方案


"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...

Hi,
using namepsace CC;



See the spelling of namespace.

-Sharad


> > using namepsace CC;


See the spelling of namespace.


Yes, sure - but that wasn''t it. I just typed it here quickly for demo
purposes...



"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...

using namepsace CC;



See the spelling of namespace.


Yes, sure - but that wasn''t it. I just typed it here quickly for demo
purposes...



Then your problem lies somewhere else. This compiles fine for me on g++
3.3.1.

namespace CC
{
void foo();
double dfoo=0;
}

namespace CC
{
void foo() {dfoo=1;}
}

using namespace CC;
int main()
{
dfoo = 2;
foo();
}


这篇关于玩名称空间......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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