警告模板功能 [英] Warning with template functions

查看:75
本文介绍了警告模板功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个模板函数,它是这个类的成员,我在同一个类的其他成员函数中调用这个函数。但我收到警告

Hi all,

I have a template function which is member of this class and I am calling this function in of my other member functions of the same class. But I am getting the warning as

展开 | 选择 | Wrap | 行号

推荐答案

任何人都可以帮我这个警告。我陷入了困境。


谢谢
Could anyone help me with this warning.I am stuck at thi point.

Thanks



任何人都可以帮助我这个警告。我陷入了困境。


谢谢
Could anyone help me with this warning.I am stuck at thi point.

Thanks



问题是由于当前C ++编译器的工作原理模板。所有模板及其实体必须可供使用它的代码访问。这意味着你不能将声明和定义分隔成标题和源文件(尽管你可以将它们分开),就像你对非模板类和函数一样。


将它们放入同一个文件或将模板函数放在另一个文件中,并使头文件包含该文件。


如果您仍然遇到问题请告诉我。



Adrian

The problem is due to how current C++ compilers work with templates. All templates and their bodies must be accessible to the code that is using it. That means that you cannot have the declaration and the definition separated in to header and source files (though you can have them separated) like you would have for non-template classes and functions.

Either throw them in to the same file or put the template functions in another file and have the header file include that file.

Let me know if you are still having trouble.


Adrian


Adrian,


我试图在函数模板中加入声明我的头文件本身。但我仍然收到错误。


实际上在我的程序中我还在我的函数模板中使用了一个类模板。这个类模板是由某人编写的。所以我的猜测是这个警告从这个类模板开始。为了使用这个类模板,我把它的头文件包含在我的程序中。


我正在使用INTEL C ++编译器(在windows上)。 br />

如果你好,请告诉我如果我不清楚我的解释,你知道如何删除这个或者让我知道。


谢谢
Adrian,

I tried to include the declaration of the function template in my header file itself.But still I am getting the error.

Actually in my program I am also using one more class template in my function template.This class template is written by somebody.So my guess is this warning starts from this class template.To use this class template I included its header file in my program.

I am using INTEL C++ compiler (on windows).

Please let me know if you have any idea of how to remove this or let me know if I am not clear with my explanation.

Thanks


这篇关于警告模板功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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