2014-04-26 9 views
22

Dostaję następujące błędy:Uzyskiwanie błąd: ISO C++ zabrania deklaracji bez typu

ISO C++ forbids declaration of ttTreeInsert with no type

ISO C++ forbids declaration of ttTreeDelete with no type

ISO C++ forbids declaration of ttTreePrint with no type

prototype for int ttTree::ttTreePrint() does not match any in class ttTree

candidate is: void ttTree::ttTreePrint()

Oto mój plik nagłówka:

#ifndef ttTree_h 
#define ttTree_h 

class ttTree 
{ 
public: 
    ttTree(void); 
    int ttTreeInsert(int value); 
    int ttTreeDelete(int value); 
    void ttTreePrint(void); 

}; 

#endif 

Oto mój plik .cpp:

#include "ttTree.h" 

ttTree::ttTree(void) 
{ 

} 

ttTree::ttTreeInsert(int value) 
{ 
} 

ttTree::ttTreeDelete(int value) 
{ 
} 

ttTree::ttTreePrint(void) 
{ 
} 

Czy ktoś może wskazać, co powoduje te błędy? Dziękuję Ci!

Odpowiedz

39

Zapomniałaś typy powrotne w swoich definicji funkcji użytkownika:

int ttTree::ttTreeInsert(int value) { ... } 
^^^    

i tak dalej.

6

Twoje zgłoszenie jest int ttTreeInsert(int value);

Jednak twoja definicja/realizacja jest

ttTree::ttTreeInsert(int value) 
{ 
} 

Zauważ, że zwracany typ int brakuje w jego realizacji. Zamiast tego powinno być

int ttTree::ttTreeInsert(int value) 
{ 
    return 1; // or some valid int 
} 
Powiązane problemy