Question: fix this error on thise code Failed to compile / usr / bin / ld: / tmp / ccjiVUh 1 . o: in function `

fix this error on thise code Failed to compile
/usr/bin/ld: /tmp/ccjiVUh1.o: in function `main':
main.cpp:(.text+0x5e): undefined reference to `PrintMenu(std::__cxx11::basic_string, std::allocator > const&)'
/usr/bin/ld: main.cpp:(.text+0x8a): undefined reference to `ExecuteMenu(char, std::__cxx11::basic_string, std::allocator > const&, PlaylistNode*)'
collect2: error: ld returned 1 exit status
Step 1: File Structure and Class Definition
1. PlaylistNode.h - Class declaration
#ifndef PLAYLISTNODE_H
#define PLAYLISTNODE_H
#include
class PlaylistNode {
private:
std::string uniqueID;
std::string songName;
std::string artistName;
int songLength;
PlaylistNode* nextNodePtr;
public:
PlaylistNode();
PlaylistNode(const std::string& uniqueID, const std::string& songName,
const std::string& artistName, int songLength);
std::string GetID() const;
std::string GetSongName() const;
std::string GetArtistName() const;
int GetSongLength() const;
PlaylistNode* GetNext() const;
void InsertAfter(PlaylistNode* nodePtr);
void SetNext(PlaylistNode* nodePtr);
void PrintPlaylistNode() const;
};
#endif
Step 2
2. PlaylistNode.cpp - Class definition
#include "PlaylistNode.h"
#include
PlaylistNode::PlaylistNode()
: uniqueID("none"), songName("none"), artistName("none"), songLength(0), nextNodePtr(nullptr){}
PlaylistNode::PlaylistNode(const std::string& uniqueID, const std::string& songName,
const std::string& artistName, int songLength)
: uniqueID(uniqueID), songName(songName), artistName(artistName), songLength(songLength), nextNodePtr(nullptr){}
std::string PlaylistNode::GetID() const { return uniqueID; }
std::string PlaylistNode::GetSongName() const { return songName; }
std::string PlaylistNode::GetArtistName() const { return artistName; }
int PlaylistNode::GetSongLength() const { return songLength; }
PlaylistNode* PlaylistNode::GetNext() const { return nextNodePtr; }
void PlaylistNode::InsertAfter(PlaylistNode* nodePtr){
PlaylistNode* temp = this->nextNodePtr;
this->nextNodePtr = nodePtr;
if (nodePtr != nullptr){
nodePtr->nextNodePtr = temp;
}
}
void PlaylistNode::SetNext(PlaylistNode* nodePtr){
this->nextNodePtr = nodePtr;
}
void PlaylistNode::PrintPlaylistNode() const {
std::cout << "Unique ID: "<< uniqueID << std::endl;
std::cout << "Song Name: "<< songName << std::endl;
std::cout << "Artist Name: "<< artistName << std::endl;
std::cout << "Song Length (in seconds): "<< songLength << std::endl;
}
3. main.cpp
#include
#include
#include "PlaylistNode.h"
void PrintMenu(const std::string& playlistTitle);
PlaylistNode* ExecuteMenu(char option, const std::string& playlistTitle, PlaylistNode* headNode);
int main(){
std::string playlistTitle;
std::cout << "Enter playlist's title: ";
std::getline(std::cin, playlistTitle);
char choice;
PlaylistNode* headNode = nullptr;
do {
PrintMenu(playlistTitle);
std::cin >> choice;
headNode = ExecuteMenu(choice, playlistTitle, headNode);
} while (choice !='q');
// Cleanup code if necessary
return 0;
}
void PrintMenu(const std::string playlistTitle){
std::cout << playlistTitle <<" PLAYLIST MENU" << std::endl;
std::cout <<"a - Add song" << std::endl;
std::cout <<"d - Remove song" << std::endl;
std::cout <<"c - Change position of song" << std::endl;
std::cout <<"s - Output songs by specific artist" << std::endl;
std::cout <<"t - Output total time of playlist (in seconds)"<< std::endl;
std::cout <<"o - Output full playlist" << std::endl;
std::cout <<"q - Quit" << std::endl;
std::cout << "Choose an option:" << std::endl;
}
// Type your ExecuteMenu implementation here, following similar logic

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!