编译错误“expected unqualified-id”使用模板时

发布于 2024-08-19 19:21:37 字数 620 浏览 4 评论 0原文

对于我的代码,

template Signal<float>;
template Signal<bit_t>;
template Signal<byte_t>;
template Signal< std::complex<float> >;
template Signal< int >;

我收到编译错误

error at signal_T.cpp:437: error: expected unqualified-id before â;â token
signal_T.cpp:438: error: expected unqualified-id before â;â token
signal_T.cpp:439: error: expected unqualified-id before â;â token
signal_T.cpp:440: error: expected unqualified-id before â;â token
signal_T.cpp:441: error: expected unqualified-id before â;â token

编译器想告诉我什么?

我该如何修复这些错误?

For my code

template Signal<float>;
template Signal<bit_t>;
template Signal<byte_t>;
template Signal< std::complex<float> >;
template Signal< int >;

I get compilation errors

error at signal_T.cpp:437: error: expected unqualified-id before â;â token
signal_T.cpp:438: error: expected unqualified-id before â;â token
signal_T.cpp:439: error: expected unqualified-id before â;â token
signal_T.cpp:440: error: expected unqualified-id before â;â token
signal_T.cpp:441: error: expected unqualified-id before â;â token

What does the compiler want to tell me?

How can I fix these errors?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

‖放下 2024-08-26 19:21:37

您编写诸如以下内容的意图是什么:

template Signal<float>;

您是否尝试进行显式模板实例化?如果是这样,假设 Signal 是一个类模板,您需要将其更改为:

// Instantiate Signal with type float
template class Signal<float>;

如果您尝试做其他事情,请提出问题。

What is your intent in writing lines such as:

template Signal<float>;

Are you trying to do explicit template instantiation? If so, assuming Signal is a class template, you need to change that to:

// Instantiate Signal with type float
template class Signal<float>;

If you're trying to do something else, please ask a question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文