Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems pertaining to compilation of C++ application in g++ (probable cause #ifndef)
    primarykey
    data
    text
    <p>I am trying to build a Linked list application using C++ programming language &amp; features such as inheritance etc. </p> <p>I have split the interface &amp; implementation in different files but not able to compile.</p> <p>Below are the list of files </p> <p>Interface files :- node.h , abstractList.h , singleLinkedList.h</p> <p>Implementation files: singleLinkedList.cpp</p> <p>node.h</p> <pre><code>#ifndef NODE_H #define NODE_H #include &lt;iostream&gt; struct nodeType { int data; struct nodeType *next; }listNode; #endif </code></pre> <p>abstractList.h</p> <pre><code>#ifndef ABSTRACT_LIST_H #define ABSTRACT_LIST_H #include &lt;iostream&gt; #include "node.h" #include "singleLinkedList.h" class abstractList { public: virtual ~abstractList(); virtual bool isEmpty(Node* ) = 0; virtual int get(const int&amp;) = 0; virtual int indexOf(const int&amp; ) = 0; virtual Node insert(const int&amp; , const int&amp; ) = 0; virtual void delete(const int&amp; ) = 0; }; #endif </code></pre> <p>singleLinkedList.h</p> <pre><code>#ifndef SINGLE_LIST_H #define SINGLE_LIST_H #include &lt;iostream&gt; #include "node.h" #include "abstractList.h" class singleLinkedList : public abstractList { public: singleLinkedList(); ~singleLinkedList(); Node populateList( ); private: void checkIndex(); int data; Node head; }; #endif </code></pre> <p>So far i have just coded the populateList() function in the implentation file, here goes the implementation file.</p> <p>singleLinkedList.cpp</p> <pre><code>#include &lt;iostream&gt; #include "node.h" #include "singleLinkedList.h" #include "abstractList.h" Node singleLinkedList :: populateList() { Node temp; int data; temp = head; char ch; std::cout&lt;&lt;"Enter Data? (y/n) " &lt;&lt; std::endl; std::cin&gt;&gt;ch; while(ch == 'Y' || ch == 'y') { std::cout&lt;&lt;"Enter the data that you would like to store.\n"&lt;&lt;std::endl; std::cin&gt;&gt;data; temp = new Node(); temp-&gt;data = data; temp-&gt;next = head; head = temp; std::cout&lt;&lt;"Enter more data?"&lt;&lt;std::endl; std::cin&gt;&gt;"\n"&gt;&gt;ch; } return temp; } </code></pre> <p>When i give g++ -c singleLinkedList.cpp , i am getting lot of errors. I am pretty sure i have done something stupid. Can anyone please pin point my error?</p> <p>EDIT: Error Log With specfic issues.</p> <pre><code>struct nodeType { int data; struct nodeType *next; }listNode; </code></pre> <p>virtual listNode *insert();</p> <p>Is the above statement correct?</p> <p>Thanks Kelly</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload