Question: CMPSC212 Project #1: Simple Note Taker using linked list (Small question.) So I'm about to dump an incredibly amount of information and work on you

CMPSC212 Project #1: Simple Note Taker using linked list (Small question.)

So I'm about to dump an incredibly amount of information and work on you just so you'll have enough information to answer what's probably an incredibly small and easy fix.

On line 97 (The one that says "noteNode* newNode = new noteNode;" in the addNote function, there's an error I can't fix for the life of me. It's a red line under the second noteNode that says "The default constructor of noteNode cannot be referenced -- it is a deleted function." and nothing I do to fix it does literally anything. After an excessive amount of trying, I've given up on trial-erroring it, and finally resolved to get some help. Thank you in advance, seriously! You guys are the best.

Here's the header file the error is on.

(Header.h)

#pragma once #include #include #include

using namespace std;

class Date { private: int month, day, year; public: Date() : month(0), day(0), year(0) {} void setDate(string strDate) { month = stoi(strDate.substr(0, 2)); day = stoi(strDate.substr(3, 2)); year = stoi(strDate.substr(6, 4)); } string showDate() { return to_string(month) + "-" + to_string(day) + "-" + to_string(year); } int calculateDays() { return year * 365 + month * 31 + day; } };

class Note { private: string composer; Date date; string subject; string body; public: Note(string c, string d, string s, string b) : composer(c), subject(s), body(b) { date.setDate(d); } string getComposer() { return composer; } Date getDate() { return date; } string getSubject() { return subject; } string getBody() { return body; } };

struct noteNode { Note note; noteNode* next; };

class NoteList { private: noteNode* head; public: NoteList() : head(nullptr) {} void loadData(const char* filename) { ifstream file(filename); if (file.is_open()) { string line; string composer, date, subject, body; while (getline(file, line)) { if (line == "##########") { Note note = Note(composer, date, subject, body); addNote(note); composer.clear(); date.clear(); subject.clear(); body.clear(); } else if (line.substr(0, 10) == "COMPOSER: ") { composer = line.substr(10); } else if (line.substr(0, 6) == "DATE: ") { date = line.substr(6); } else if (line.substr(0, 9) == "SUBJECT: ") { subject = line.substr(9); } else { body += line + " "; } } file.close(); } else { cerr << "Unable to open file " << filename << endl; } } void addNote(Note note) { noteNode* newNode = new noteNode; //The error. newNode->note = note; newNode->next = head; head = newNode; } void listNotesByDate() { noteNode* curr = head; while (curr != nullptr) { if (curr->note.getBody() != "") { cout << curr->note.getComposer() << " " << curr->note.getSubject() << " " << curr->note.getDate().showDate() << endl; } curr = curr->next; } } void listNotesByComposer(string composerName) { noteNode* curr = head; while (curr != nullptr) { if (curr->note.getBody() != "") { string composerInput; cout << "Enter the composer: "; if (curr->note.getComposer() == composerInput) { cout << curr->note.getComposer() << " " << curr->note.getSubject() << " " << curr->note.getDate().showDate() << endl; } else { } } curr = curr->next; } } void deleteFrontNote() { noteNode* curr = head; noteNode* prev = NULL; if (head == NULL) { return; } else { prev = curr; curr = curr->next; head = curr; delete prev; } cout << " The latest note has been deleted."; } };

That might be all you need, but just in case, here's the source file and the text file:

(Source.ccp)

#include "Header.h"

int main() { NoteList noteList; noteList.loadData("input.txt");

bool finish = false; int choice; while (finish != true) { cout << " ** Menu ** " << "1. LIST NOTES BY DATE " << "2. LIST NOTES BY COMPOSER " << "3. DELETE MOST RECENT NOTE " << "4. EXIT " << endl; cin >> choice; if (choice == 1) { NoteList::listNotesByDate; } else if (choice == 2) { NoteList::listNotesByComposer; } else if (choice == 3) { NoteList::deleteFrontNote; } else if (choice == 4) { cout << " Operations terminated."; finish = true; } else { cout << " Input not recognized. Please choose a number between 1 and 4." << endl; } }

(input.txt)

COMPOSER: yson DATE: 01-21-2021 SUBJECT: Picking up BODY: Reminder: Pick up vegetables for dinner after work. ########## COMPOSER: hskim DATE: 01-22-2019 SUBJECT: Dr. Appointment BODY: Dental office appointment at 3:00, tomorrow. ########## COMPOSER: yson DATE: 11-20-2021 SUBJECT: Team meeting BODY: Team meeting will be held on March 11, 2022, from 1:30 - 3:30 p.m. In the process of hiring a new worker. ##########

The error I've been having is also preventing me from being able to test the rest of my code like I want too, so if you're bored or trying to kill time and see a problem in the code that I haven't noticed, please don't be afraid to mention it!

(Let me know if you need the project instructions for any reason!)

Sorry for the large dump of information that you probably only needed 1/16th of. Thanks in advance!

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 Databases Questions!