gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:05:34 25 4
gpt4 key购买 nike

在我的代码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>

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com