关于成员职能的问题 [英] question on member functions

查看:44
本文介绍了关于成员职能的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个跨越多个文件的c ++程序。如何在另一个文件中调用成员

函数?


谢谢,

Santosh

解决方案

" SK" <有关********* @ sbcglobal.net>在消息中写道

新闻:IW *********************** @ newssvr30.news.prod igy.com ...... < blockquote class =post_quotes>我有一个跨越多个文件的c ++程序。如何在另一个文件中调用成员
函数?




1.请不要多发帖子,而是交叉发帖,如果你想要将相同的消息发布到多个组中。


2.看到我对你发布的同一消息的回复

acllc-c ++。


3.如果您发现了网络礼仪,并且完成了上述#1,我会不会浪费我的时间来写这篇文章。< br $>

4.你的课本在哪里?


-Mike


SK写道:

我有一个跨越多个文件的C ++程序。
如何在另一个文件中调用成员函数?



类定义必须出现在* every * translation单元中。

通常,类定义放在头文件中

包含在顶部附近每个源文件

(翻译单位)。


你的链接编辑器会广告所有目标文件

由您的编译器创建并解析所有未定义的链接

到其他文件中定义的函数。


Mike Whaler给出了很好的一般建议

,你可以好好遵循。


" E. Robert Tisdale <,E ************** @ jpl.nasa.gov>。在留言中写道

新闻:3F ************ @ jpl.nasa.gov ...

SK写道:

我有一个跨越多个文件的C ++程序。
如何在另一个文件中调用成员函数?



类定义必须出现在每个*翻译单元中。




真的吗?我以为它只需要宣言。不是链接器组合

代码?

-

加里


I have a c++ program that spans multiple files. How do I call member
functions in one file from the other?

Thanks,
Santosh

解决方案

"SK" <on*********@sbcglobal.net> wrote in message
news:IW***********************@newssvr30.news.prod igy.com...

I have a c++ program that spans multiple files. How do I call member
functions in one file from the other?



1. Please don''t mult-post, but cross-post instead if you
want to post the same message to more than one group.

2. See my reply to the same message you posted at
acllc-c++.

3. Had you observed netiquette and done #1 above, I would
not be wasting my time writing this.

4. Where is your textbook?

-Mike


SK wrote:

I have a C++ program that spans multiple files.
How do I call member functions in one file from the other?



The class definition must appear in *every* translation unit.
Usually, the class definition is placed in a header file
which is included near the top of every source file
(translation unit).

Your link editor will load all of the object files
created by your compiler and resolve all of the undefined links
to functions defined in other files.

Mike Whaler gives good general advice
which you would do well to follow.


"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:3F************@jpl.nasa.gov...

SK wrote:

I have a C++ program that spans multiple files.
How do I call member functions in one file from the other?



The class definition must appear in *every* translation unit.



Really? I thought it only needed the declaration. Won''t the linker combine
the code?
--
Gary


这篇关于关于成员职能的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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