title: Why am I getting error: initializing argument 1 of 'Item::Item(int)' [-fpermissive] in Eclipse when I try to compile my C++ code?
body: <p>I'm new to C++, and have finally given up on trying to get this to compile after staring at it for too long. The compiler seems to be rejecting the constructor prototype in the header file for some reason... I can't figure out what's wrong with it.</p>
  
  <p>Item.h:</p>
  
  <pre><code>#ifndef ITEM_H_
  #define ITEM_H_
  
  
  class Item {
  public:
      Item(int); //This line is what Eclipse keeps flagging up with the error in the title
      virtual ~Item();
      Item* getNextPtr();
      int getValue();
      void setNextPtr(Item *);
  };
  
  #endif /* ITEM_H_ */
  </code></pre>
  
  <p>In my Item.cpp file I have:</p>
  
  <pre><code>int val;
  Item* nextPtr = 0;
  Item::Item(int value) {
      val = value;
  }
  
  Item* Item::getNextPtr() {
      return nextPtr;
  }
  
  void Item::setNextPtr(Item *nextItem) {
      nextPtr = nextItem;
  } 
  
  int Item::getValue() {
      return val;
  }
  
  Item::~Item() {
      // TODO Auto-generated destructor stub
  } 
  </code></pre>
  
  <p>Oops, I'm using GCC. And yeah, they should have been member variables! How do I go about doing that using this format? The code where I use instantiate Item is below. I am aware that there should be no global variables in that either...</p>
  
  <pre><code>#include "LinkList.h"
  #include "Item.h"
  
  Item* first = 0;
  int length = 0;
  
  LinkList::LinkList(int values[], int size) {
      length = size;
      if (length &gt; 0) {
          Item firstItem = new Item(values[0]);
          Item *prev = &amp;firstItem;
          first = &amp;firstItem;
          for (int i = 0; i &lt; size; i++) {
              Item it = new Item(values[i]);
              prev-&gt;setNextPtr(&amp;it);          //set 'next' pointer of previous item to current item
              prev = &amp;it;                     // set the current item as the new previous item
          }
  
      }
  }
  
  LinkList::~LinkList() {
      for (int i = 0; i &lt; length; i++) {
          Item firstItem = *first;
          Item *newFirst = firstItem.getNextPtr();
          delete(first);
          first = newFirst;
      }
  }
  
  int LinkList::pop() {
      Item firstItem = *first;
      first = firstItem.getNextPtr();
      return firstItem.getValue();
  }
  </code></pre>
  
  <p>I've just noticed a bug with the functionality of the pop() and destructor functions... please ignore those, I just want to figure out what's wrong with the instantiation of Item.</p>
  
  <p>GCC error:</p>
  
  <pre><code>Info: Internal Builder is used for build
  g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\LinkList.o" "..\\src\\LinkList.cpp" 
  ..\src\LinkList.cpp: In constructor 'LinkList::LinkList(int*, int)':
  ..\src\LinkList.cpp:16:38: error: invalid conversion from 'Item*' to 'int' [-fpermissive]
  ..\src\/Item.h:14:2: error:   initializing argument 1 of 'Item::Item(int)' [-fpermissive]
  ..\src\LinkList.cpp:20:32: error: invalid conversion from 'Item*' to 'int' [-fpermissive]
  ..\src\/Item.h:14:2: error:   initializing argument 1 of 'Item::Item(int)' [-fpermissive]
  
  21:24:26 Build Finished (took 256ms)
  </code></pre>