2014-02-22 3 views
0

최근 C에서 작업했지만 C++을 배우기 시작했습니다. 나는 텍스트를 읽고 유실 텍스트에서 데이터를 구성하는 프로그램을 만들기 위해 숙제가있었습니다. 이것이 내가 남긴 마지막 부분이지만 내 코드에 문제가있는 것은 아닙니다. 문제의이 부분은 매우 간단하지만 여전히 내 오류가 무엇인지 이해하지 못합니다. 나는 주로 세그먼트 화 오류를 작성한 gcc 컴파일러에 익숙해졌지만 g ++ 컴파일러 오류는 다릅니다. c에서 C++로 전환하는 동안 더 많은주의를 기울여야 할 팁이나 힌트가 있으면 정말 감사하겠습니다.C++에서 연결된 목록 인쇄시 오류 이해

이것은 내 출력 오류입니다.

-bash-3.2$ g++ -o Printfunction Printfunction.cpp 
Printfunction.cpp: In function 'void Printfunction(wordList*)': 
Printfunction.cpp:43: error: cannot convert 'NumberList*' to 'Numberlist*' for argument '1' to 'std::string returnlist(Numberlist*)' 
Printfunction.cpp: In function 'std::string returnlist(Numberlist*)': 
Printfunction.cpp:56: error: invalid use of undefined type 'struct Numberlist' 
Printfunction.cpp:10: error: forward declaration of 'struct Numberlist' 
Printfunction.cpp:56: error: 'to_string' was not declared in this scope 
Printfunction.cpp:57: error: invalid use of undefined type 'struct Numberlist' 
Printfunction.cpp:10: error: forward declaration of 'struct Numberlist' 

제 코드에 어떤 문제가 있습니까?

#include <iostream> 
#include <string> 
#include <iomanip> 

using namespace std; 

struct NumberList 
{ 
    int line; 
    struct Numberlist *nextPtr; 
}; 

struct wordList 
{ 
    string word; 
    int Count; 
    NumberList lines; 
    struct wordList *nextPtr; 
}; 

void Printfunction(wordList *list); 
string returnlist(Numberlist *list); 

int main() 
{ 
    wordList something; 
    something.word = "SOMETHING"; 
    something.Count = 55555; 
    something.nextPtr = NULL; 
    Printfunction(&something); 

} 

void Printfunction(wordList *list) 
{ 
    int i; 
    i=1; 
    cout<<"+----+----------------------------+-------+---------------------------------+"<<endl; 
    cout<<"|# |   WORD    | COUNT |    LINES    |"<<endl; 
    cout<<"+----+----------------------------+-------+---------------------------------+"<<endl; 
    while(list != NULL) 
    { 
     cout<<"|"<<left<<setw(4)<<i<<"|"<<left<<setw(28)<<list->word<<"|"<<left<<setw(7)<<list->Count<<"|"<<left<<setw(33)<<returnlist(&(list->lines))<<"|"<<endl; 
     cout<<"+----+----------------------------+-------+---------------------------------+"<<endl; 
     list = list->nextPtr; 
     i++; 
    } 
} 

string returnlist(Numberlist *list) 
{ 
    string final; 
    while(list != NULL) 
    { 
     final.append(", "); 
     final.append(to_string(list->line)); 
     list = list->nextPtr; 
    } 
    final.append("."); 
    return final; 
} 

답변

4

문제는 때때로 당신이 그것을 NumberList 철자, 때로는 당신이 그것을 Numberlist 철자 것입니다. 더 많은 관심을

케이스 문제를 지불해야하는지에

모든 팁이나 힌트.

+0

@vatomargvelashvili : 예 : –

+0

내가 그것을 대답있어 수 없기 때문에 :( – Vato

+0

@vatomargvelashvili : to_string이 작동하지 않는 이유 teehee –