I'm making a singly Linked List called Tracks, why is it throwing exception when I try to make a ptr
of type Tracks
and assign head
to it. It also gives same error when I assign mbidd
value to node->trackRef->mbid
template <typename T1> class Tracks { public: //data members T1 trackNumber; MMD<T1,string, float>* trackRef; //connections Tracks* next; Tracks* head; Tracks() { next = nullptr; head = nullptr; trackNumber = 0; trackRef->mbid = 0; //mbid is data member of MMD } Tracks* createList(T1 tN, T1 mbidd) { Tracks<T1>* node= new Tracks<T1>(); Tracks<T1>* ptr = new Tracks<T1>(); ptr = head; //gives error node->trackNumber = tN; node->trackRef->mbid = mbidd; //gives error if (head == nullptr) { head = node; node->next = nullptr; } else { while (ptr->next != nullptr) ptr = head->next; ptr->next = node; } return head; } };
https://stackoverflow.com/questions/67327613/exception-thrown-read-access-violation-linked-list April 30, 2021 at 10:53AM
没有评论:
发表评论