0
vlist.h我無法創建一個鏈表指向的對象在另一個類
class Vlist
{
public:
Vlist();
~Vlist();
void insert(string title, string URL, string comment, float length, int rating);
bool remove();
private:
class Node
{
public:
Node(class Video *Video, Node *next)
{m_video = Video; m_next = next;}
Video *m_video;
Node *m_next;
};
Node* m_head;
};
的main.cpp
int main()
{
....blah blah.... (cin the values)
Array[i] = new Video(title, URL, comment, length, rating);
Vlist objVlist;
objVlist.insert(title, URL, comment, length, rating);
}
vlist.cpp
這是錯誤來自何處
(m_head = new Node(Video, NULL);
...這個函數的作用是將一個指向從類視頻的對象插入到列表中。
void Vlist::insert(string title, string URL, string comment, float length, int rating)
{
Node *ptr = m_head;
//list is empty
if(m_head == NULL)
m_head = new Node(Video, NULL);
else
{
ptr = ptr->m_next;
ptr = new Node(Video, NULL);
}
//sort the list every time this executes
}
video.h
這是我試圖指向使用鏈表類。
class Video
{
public:
Video(string title, string URL, string comment, float length, int rating);
~Video();
void print();
bool longer(Video *Other);
bool higher(Video *Other);
bool alphabet(Video *Other);
private:
string m_title;
string m_url;
string m_comment;
float m_length;
int m_rating;
};
第一次使用堆棧溢出,不太確定會發生什麼。
當您編寫「這是錯誤來自哪裏」時,任何人都不明白該錯誤是什麼。添加錯誤描述會很有禮貌。 – molbdnilo 2013-03-12 10:31:22