c++ - 类型不完整错误(E0409、E0070、E0515)

标签 c++ tuples incomplete-type

在我的代码中Main.cpp我有如下所示的内容。我遇到的问题是 tuple<int, int, int> 我不断收到这三个错误

function "sPA" returns incomplete type "trie" , incomplete type is not allowed , 和 cannot convert to incomplete class "trie"

我在这里做错了什么会犯这个错误?

 // Main.cpp
 #include <iostream>
 #include <string>
 using namespace std;

 typedef pair<int, int> int_pair;
 typedef tuple<int, int, int> trie;



 int_pair sum_and_product(int a, int b) {
     return int_pair(a + b, a * b);
 }

 trie sPA(int a, int b, int c) {
     trie t{ a + b + c,a * b * c,((a + b + c) / 3) };
     return t;
 } 

 void consuming_templates() {
     int a = 2, b = 3, c = 4;
     auto results = sum_and_product(a,b);
     cout << "sum = " << results.first << "|product = " << results.second << endl;
     auto r2 = sPA(a, b, c);
 }

int main(int argc, char* argv[]) {

    consuming_templates();

    return 0;
}

最佳答案

idclev 463035818 和 M.M 发表评论来回答我的问题

你需要做#include <tuple>#include <utility>

关于c++ - 类型不完整错误(E0409、E0070、E0515),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60310208/

相关文章:

c++ - 导出静态库的成员函数

c++ - 我怎样才能得到一个 v8 函数来返回一个 C++ 对象?

c++ - 分离配置和算法代码的最佳实践

c++ - 在类范围内将指针传递给 constexpr 函数时是否滥用推断父模板的参数

类定义中的 c++ friend 类关键字

c++ - 如何在 C++11 中为包装函数参数解包元组?

python - 访问 python 元组中的特定条目

swift - 如何在 Swift 中声明一个元组并为其成员之一提供运行时函数

c++ - std::is_copy_constructable 对于 std::vector

c++ - 不完整的类 : Convert void* to pointer to class type via dynamic_cast