Unfamiliar Compilation Errors In a Linked List Class (C++)

In summary, the conversation is about a final project for a class where the assignment is to create a linked list of personal records and perform operations on it. The person is currently working on the "List.h" class and has also implemented a "Person.h" class which is composed of 3 subclasses - "Address.h", "Date.h" and "Name.h". They have attached all of these files as text files since they are not allowed to attach .h files. However, they are facing compilation errors when trying to compile "List.h", with the most serious error being that their Node struct is implicitly deleted. They are seeking help on how to solve this issue without redoing their work.
  • #1
rtareen
162
32
Homework Statement
This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. The linked list should be implemented as its own class.
Relevant Equations
none
Hi all. I'm working on my final project for a class. The assignment is to have a linked list of personal records, and then do some things with it. Right now I'm working on the linked list class "List.h". I've implemented a Person class "Person.h" as a composition of 3 subclasses "Address.h", "Date.h" and "Name.h". I've attached all of these as text files (I'm not allowed to attach .h files?). I'm able to compile "Address.h", "Date.h", "Name.h" and "Person.h" without any issues. But when I'm trying to compile "List.h" I get some serious compilation errors (attached). The most serious is the one that says my Node struct is implicitly deleted. I need some help on how to solve this without re-doing everything I've already done. Please help.
errors.jpg
 

Attachments

  • Date.txt
    1.3 KB · Views: 98
  • Name.txt
    598 bytes · Views: 99
  • Person.txt
    952 bytes · Views: 98
  • List.txt
    1.1 KB · Views: 107
Physics news on Phys.org
  • #2
My Address.txt file is not showing up so I'm pasting it here
Edit by moderator: Added code tags
C++:
include <iostream>
#include <string>
using std::cout;
using std::string;

class Address
{
    public:
        Address(int num = 0, string name = "Default Rd", int unit = 0, string town = "Deafult City", string _state = "AK", string zipCode = "00000")
        {
            setStreetNumber(num);
            setStreetName(name);
            setUnitNumber(unit);
            setCity(town);
            setState(_state);
            setZip(zipCode);
        }
        void setStreetNumber(int num)
        {
            if (num < 0)
            {
                cout << "Invalid street number. Setting to default value: 0.\n";
                streetNumber = 0;
            }
            else
                streetNumber = num;
        } 
        void setStreetName(string name)
        {
            streetName = name;
        }
        void setUnitNumber(int unit)
        {
            if (unit < 0)
            {
                cout << "Invalid unit number. Setting to default value: 0.\n";
                unitNumber = 0;
            }
            else
                unitNumber = unit;
        }
        void setCity(string town)
        {
            if(town.length() > 20)
            {
                town = town.substr(0,20);
                cout << "City name too large. Limiting to 20 characters.\n";
            }
            city = town;
        }
        void setState(string _state)
        {
            if(_state.length() != 2)
            {
                cout << "State must be 2 characters. Setting to default value: AK.\n";
                state = "AK";
            }
            else
            {
                for(int i = 0; i < 2; i++)
                    _state[ i] = toupper(_state[ i]);
                state = _state;
            }
        }
        void setZip(string zipCode)
        {
            if (zipCode.length() > 5)
            {
                cout << "Zip code too long. Limiting to 5 characters.\n";
                zipCode = zipCode.substr(0,5);
                zip = zipCode;
            }
            else if( zipCode.length() < 5)
            {
                cout << "Zip code too short. Setting to deafault value: 00000.\n";
                zip = "00000";
            }
            else
                zip = zipCode;
        }
        int getStreetNumber()
        {
            return streetNumber;
        }
        string getStreetName()
        {
            return streetName;
        }
        int getUnitNumber()
        {
            return unitNumber;
        }
        string getCity()
        {
            return city;
        }
      
        string getState()
        {
            return state;
        }
        string getZip()
        {
            return zip;
        }
  
    private:
        int streetNumber;
        string streetName;
        int unitNumber;
        string city;
        string state;
        string zip;
};
 
Last edited by a moderator:
  • #3
rtareen said:
But when I'm trying to compile "List.h" I get some serious compilation errors (attached). The most serious is the one that says my Node struct is implicitly deleted.
Your attachment, errors.jpg, is impossible for me to read. I can barely read the lines with white text, but the lines that describe errors are red against a black background, which makes them impossible for me to read. Please copy the contents of the compiler output as text and post it directly, not as an image.
 
  • Like
Likes pbuk

1. What is a linked list in C++?

A linked list is a data structure in C++ that consists of a series of nodes, each containing a value and a pointer to the next node in the list. This allows for efficient insertion and deletion of elements in the list, as well as dynamic memory allocation.

2. What are some common compilation errors that can occur in a linked list class?

Some common compilation errors in a linked list class include syntax errors, such as missing semicolons or incorrect variable names, as well as logical errors, such as accessing a null pointer or using an uninitialized variable.

3. How can I fix unfamiliar compilation errors in a linked list class?

The best way to fix unfamiliar compilation errors in a linked list class is to carefully read the error messages and use a debugger to pinpoint the source of the error. It may also be helpful to review the code and check for any potential mistakes or typos.

4. Why am I getting a "template instantiation depth exceeds maximum" error in my linked list class?

This error occurs when the compiler is unable to instantiate a template due to the number of nested template instantiations exceeding the maximum allowed depth. This can happen if there are too many recursive function calls or if the linked list class is too complex.

5. How can I optimize my linked list class to avoid compilation errors?

To optimize a linked list class and avoid compilation errors, it is important to carefully design the class and its functions, avoiding unnecessary recursion or complex code. It may also be helpful to use a debugger and run tests to catch any potential errors early on.

Similar threads

  • Programming and Computer Science
Replies
22
Views
2K
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
15
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
Back
Top