struct在普通的G++,中的工作中工作

发布于 2025-02-09 19:13:32 字数 533 浏览 1 评论 0原文

我在QT中做了一个计算器GUI,并单独做出了一个可以使C ++中的计算的函数,但是在尝试将两者与.h文件结合起来后,我得到了错误:> 每当我使用struct最小可重复可重复的示例时,都没有用于计算:: token的匹配构造函数

#include <string>

namespace calculation
{
struct token
{
    std::string type;
    double value = -1;
    std::string value_string;
};

void test(){
    // Works fine in g++, error in Qt
    token test{"test",0,"test"};
    return;
    }
}
int main(){
    calculation::test();
    return 0;
}

再次在标准G ++中起作用,但在QT中产生相同的错误

I made a calculator GUI in Qt and separately I made a function that can tokenize and evaluate calculations in c++, but upon attempting to combine the both with a .h file, i got the error: no matching constructor for intialization of calculation::token whenever I used a struct

Minimal reproducible example:

#include <string>

namespace calculation
{
struct token
{
    std::string type;
    double value = -1;
    std::string value_string;
};

void test(){
    // Works fine in g++, error in Qt
    token test{"test",0,"test"};
    return;
    }
}
int main(){
    calculation::test();
    return 0;
}

Once again, this works in standard g++, but produces the same error in qt

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文