0

I have this error only on VS 2019, I did the same code in Codeblocks and it works good, I want to know if you can help me with this error.

In the class LinkedList when I try to declare the "header" and "trailer" Nodes the compiler says:

C3646 - 'header': unknown override specifier

C4430 - missing type specifier - int assumed. Note: C++ does not support default-int

C3646 - 'trailer': unknown override specifier

C4430 - missing type specifier - int assumed. Note: C++ does not support default-int

This is the code of the class LinkedList and Node, each class is in a separate ".h" file.

"LinkedList.h" :

#pragma once

#include "Node.h"

#include <iostream>

using namespace std;

class LinkedList

{

public:

    LinkedList();
    ~LinkedList();

    int getFront() const;
    int getBack() const;

    void addFront(int d);
    void addBack(int d);
    void removeFront();
    void removeBack();

    void PrintReverse();
    void PrintForward();


private:

     Node header;
     Node trailer;

};

"Node.h":

#pragma once

#include <iostream>

#include "LinkedList.h"

using namespace std;

class Node
{

private:

    int data;
    Node* next;
    Node* prev;

    void addFrontN(int d);
    void removeFrontN();

public:

    friend class LinkedList;

};
Paul T.
  • 4,703
  • 11
  • 25
  • 29
Danny_935
  • 11
  • 1
  • 4
  • 2
    Remove `#include "LinkedList.h"` from Node.h . You have circular includes, but you don't actually need them. – Igor Tandetnik Feb 02 '20 at 00:05
  • Does this answer your question? [Resolve build errors due to circular dependency amongst classes](https://stackoverflow.com/questions/625799/resolve-build-errors-due-to-circular-dependency-amongst-classes) – drescherjm Feb 02 '20 at 01:09

0 Answers0