-2

I am trying to append a node but I keep getting the error incomplete type 'struct familyFinace' how do I fix this?

   #include <iostream>
#include <iomanip>
#include <fstream>
#include <familyFinance>

using namespace std;
struct familyFinance{                     
  int acctNos; float Balance; familyFinance *nextNodePointer;  familyFinance *ptrHead;  familyFinance *dynFinancePtr;
      };

void printOnesBelowThreshold (float , int [], float [], int );
void spitThemOut(struct familyFinace);
void anyBelowThreshold(struct familyFinance [], int , float,
      struct familyFinance &); 

int main() {
 

  int noAccounts = 7, Option; float Threshold;
  struct familyFinance startNodeOption3 ;

  familyFinance financeAry[10];

  ifstream Lab3DataFileHandle;
  int num;
  float money;
 
familyFinace *ptrHead=nullptr;
familyFinace *dynFinancePtr=nullptr;
 familyFinace *tempPtr;
 tempPtr=ptrHead;

  Lab3DataFileHandle.open("Lab5Data.txt");
  while (!Lab3DataFileHandle.eof( )) {
    familyFinance *dynFinancePtr= new familyFinance;


 Lab3DataFileHandle >> dynFinancePtr -> acctNos; 
 Lab3DataFileHandle >> dynFinancePtr -> Balance;
 
 familyFinace  *ggnextNodePointer = nullptr;
  if (ptrHead == nullptr)  
   familyFinance *ptrHead  = dynFinancePtr;
else {      
 tempPtr =  ptrHead;  

down bellow is the main problem with the code on these lines I get invalid use of incomplete type 'struct familyFinace'

 while  (tempPtr -> nextNodePointerx != nullptr )
    tempPtr = tempPtr->nextNodePointer;
      tempPtr->nextNodePointer = dynFinancePt
Pokmons222
  • 49
  • 7
  • With the given code it is impossible to help you. Try to boil the problem down to a minimal example containing all relevant parts. – JoKing Jul 22 '20 at 20:05
  • What is `familyFinace` supposed to be? There is no mention of that type anywhere in this code. And why are you implementing a linked-list manually instead of using `std::list` or `std::forward_list`? – Remy Lebeau Jul 22 '20 at 20:21
  • It seems unlikely that code produces that error message since `familyFinace` appears nowhere within it. Seems like you got confused about what code you are actually compiling. – john Jul 22 '20 at 20:22
  • I just edited the question the proper code is now up. – Pokmons222 Jul 22 '20 at 20:45
  • Is it just a typo? `familyFinace` should be `familyFinance`? – Alan Birtles Jul 22 '20 at 20:59
  • You did not show your header file, so we can't say much here. The code as is now compiles in g++ 5.4.0 if the header is commented out and the missing braces at the end are added. – Palo Jul 22 '20 at 23:04
  • One error is here, `void spitThemOut(struct familyFinace);` it should be `void spitThemOut(familyFinance);`. You are asking for trouble by repeatedly using the keyword `struct` where it isn't needed. If you make a typo (like the example I mentioned) then the `struct` keyword is going to hide it. – john Jul 23 '20 at 07:07

2 Answers2

0

invalid use of incomplete type 'struct familyFinace'

how do I fix this?

Include the header for familyFinance before using the type. The compiler needs to see how the type is declared before you can use it.

Remy Lebeau
  • 454,445
  • 28
  • 366
  • 620
Jesper Juhl
  • 1
  • 3
  • 38
  • 63
-1

An incomplete type error can in some cases be fixed by forward declaration. Just put struct familyFinance somewhere in the global scope above the line that produces this error, e.g. right after using namespace std;

JoKing
  • 408
  • 3
  • 11
  • 2
    Incomplete type errors are **caused** by forward declarations. A class that has only been forward declared is an incomplete type. – john Jul 22 '20 at 20:23