Неполная ошибка типа (E0409, E0070, E0515) - PullRequest
1 голос
/ 20 февраля 2020

В моем коде 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;
}

1 Ответ

2 голосов
/ 20 февраля 2020

idclev 463035818 и ММ разместил комментарий, чтобы ответить на мой вопрос

Вам нужно сделать #include <tuple> и #include <utility>

...