Search code examples
c++tuplesincomplete-type

Incomplete type error (E0409, E0070, E0515)


In my code Main.cpp I have the following shown below. The issue I am running into us with tuple<int, int, int> I keep getting these three errors

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

What am I doing wrong here to make this error?

 // 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;
}

Solution

  • idclev 463035818 and M.M has posted the comment to answer my question

    You need to do #include <tuple> and #include <utility>