English 中文(简体)
如何为全球职能增加模板参数?
原标题:how to add template parameter to global function?

我与一些遗产法典合作,并试图将其编成文。 最初是在视力室建造的,其编辑没有达到标准。 任何途径,现在我穿过固定的法典,我穿过在全球宣布的模版功能。 我发现错误:

/home/blah/blah;/blah.h:78: error: there are no arguments to ‘Clip’ that depend on a template parameter, so a declaration of ‘Clip’ must be available

我在这样作之前就能够通过做我的地图集来纠正这一错误: 然而,由于它没有范围,我如何解决这个问题?

更新:此处是口头功能声明:

template<class T> inline T Clip( T x, T bot, T top )
{ return(( x>=bot && x<=top ) ? x : (( x<bot ) ? bot : top )); }

Clip:

src_row = Clip( dst_row + h, 0, SR ); 
//dst_row + h, 0, SR are all int s... does that help?
//btw, love the quick responses, thanks.

电话和声明有不同的卷宗。

最佳回答

在模板定义之前的某个地方宣布<代码>Clip造成这一错误。 http://www.ohchr.org。 其本身不是一个模板,普通声明将照此办理。 如果<代码>Clip是一个功能模板,你发现<编码>Clip的定义,你通常只能复制该定义的开始,并将<代码>{>><>>>>>><>/代码>改为<代码>;获取有效声明。

Edit: Okay, 因此,你发现Clip的定义,请在单页上说明。 你的汇编错误也存在问题。

最好做的是,在问题顶点附近添加<代码>#include <clip.h>。 • 确保两人都有警卫,防止出现多胎。

但是,如果引入循环头脑依赖,这可能不会奏效。 如添加<代码>#include 造成不同的错误,你可以试图在给出错误定义之前将<代码>Clip的声明(而不是定义)放在问题。 这是你仅复制、复制和替换{......}的>;。

template<class T> inline T Clip( T x, T bot, T top );
问题回答

您也许能够利用重新渗透的经营者来解决这一问题。 与此类似:

::Clip<params>(...);

但是,它很难确切地告诉你什么问题。 请登录代码和插图;确切的错误信标。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签