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

Incomplete type error (E0409, E0070, E0515)

本文关键字:E0070 E0515 E0409 类型 错误      更新时间:2023-10-16

在我的代码Main.cpp中,我有如下所示。我用tuple<int, int, int>遇到的问题我一直收到这三个错误

function "sPA" returns incomplete type "trie"incomplete type is not allowedcannot 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>