2016-04-19 8 views
0
#include<iostream> 
#include<stdlib.h> 
#include<conio.h> 
#include <ctime> 
#include <fstream> 
#include <windows.h> 
#include <string> 
using namespace std; 


/* data variable is used to store data as name 
suggests,the "next" is a pointer of the type node 
that is used to point to the next node of the 
Linked List*/ 
/* 
* Node Declaration 
*/ 
struct node 
{ 
    string info; 
    struct node *next; 
}*start; 

/* 
* Class Declaration 
*/ 
class single_llist 
{ 
    public: 
    node* create_node(string); 
    void insert_begin(); 
    void insert_pos(); 
    void insert_last(); 
    void delete_pos(); 
    void sort(); 
    void search(); 
    void update(); 
    void reverse(); 
    void display(); 
    single_llist() 
    { 
     start = NULL; 
    } 
}; 

/* 
* Inserting element in beginning 
*/ 
void single_llist::insert_begin() 
{ 
    string value; 
    cout<<"Enter the value to be inserted: "; 
    cin>>value; 
    struct node *temp, *p; 
    temp = create_node(value); 
    if (start == NULL) 
    { 
    start = temp; 
    start->next = NULL;   
    } 
    else 
    { 
    p = start; 
    start = temp; 
    start->next = p; 
    } 
    cout<<"Element Inserted at beginning"<<endl; 
} 

をして文字列ノードの定義はthem.Therefore私はプログラムがこれを与えstring.Theを扱っていますエラー:undefined reference to single_llist::create_node(std::string)ここに間違いがあることを私に見せてください。temp = create_node(value);この問題を解決するために何をする必要があるのか​​、まだ研究していますか?リンクリスト私はDevのC++ program.Iはtxtファイルに特定の単語を入力しようとして保存すると、私のプログラムを開発してい

+1

'create_node'関数を定義しましたか? – NathanOliver

答えて

0

ありがとう@NathanOliver私は、最初にノードを作成せずに間違った方法を試みたと思う。

/* 
* Creating Node 
*/ 
node *single_llist::create_node(string value) 
{ 
struct node *temp, *s; 
temp = new(struct node); 
if (temp == NULL) 
{ 
    cout<<"Memory not allocated "<<endl; 
    return 0; 
} 
else 
{ 
    temp->info = value; 
    temp->next = NULL;  
    return temp; 
} 
} 
+0

これは答えか質問の補遺であるはずです。これが質問の詳細な情報の場合は、質問の下にある編集リンクを使用して質問にこの情報を追加し、この回答を削除してください。これが答えであれば、より多くの説明が必要です。 – user4581301

+0

はい、私にとっては答えです。なぜなら、 'single_llist :: create_node(std :: string)'への未定義の参照はcreate_node関数が存在しないためであったからです。また、ノードの作成時にコードを与えて他の人にも役立つかもしれません。ありがとう@ user4581301 –

関連する問題