title: Illegal call of non-static member function
body: <p>I wish to make a calculator that can calculate numbers of almost any length.</p>
  
  <p>The first function that I needed is one that converts a string into a linked list and then returns a pointer to the head of the list.</p>
  
  <p>However, when compiling I am faced with an error:
  error C2352: 'main::StringToList' : illegal call of non-static member. Line: 7;</p>
  
  <p>I provide you with my main.cpp and main.h files.</p>
  
  <p>Thanks for any</p>
  
  <h2>main.cpp</h2>
  
  <pre><code>#include "main.h"
  
  int main()
  {
  main::node *head = main::StringToList("123");
  
  main::node *temp = new main::node;
  
  temp = head;
  while (temp-&gt;next != NULL)
  {
      cout &lt;&lt; temp-&gt;data;
      temp = temp-&gt;next;
  }
  
  std::cout &lt;&lt; "\nThe program has completed successfully\n\n";
  system("PAUSE");
  return 0;
  }
  
  main::node * StringToList(string number) 
  {
  
  int loopTimes = number.length() - 1; 
  int looper = 0;         
  int *i = new int;       
  i = &amp;looper;            
  main::node *temp = new main::node;  
  main::node *head;               
  head = temp;            
  for ( i = &amp;loopTimes ; *i &gt;= 0; *i = *i - 1) 
  {
      temp-&gt;data = number[*i] - 48;   
      main::node *temp2 = new main::node;         
      temp-&gt;next = temp2;             
      temp = temp2;                   
  }
  temp-&gt;next = NULL;                  
  return head;
  }
  </code></pre>
  
  <h2>main.h</h2>
  
  <pre><code>#ifndef MAIN_H
  #define MAIN_H
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class main
  {
  public:
  typedef struct node
  {
      int data;
      node *next;
  };
  node* StringToList (string number);
  };
  
  #endif
  </code></pre>