Depth-first search algorithm implementation
<p>The following C++ Depth-first search program won't compile.</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

class Stack
{

private:
      const int size=20;
      int *st;
      int top;
public :
      Stack(){
    st =new int[size];
    top=-1;

      }
      ~Stack(){
          delete[] st;
          top=-1;
      }
      void push(int j){
          st[++top]=j;
              }
      int pop(){
          return st[top--];
      }
      int peek(){

          return st[top];

      }
       bool empthy(){
           return (top==-1);

       }
};
class Vertex{
public:
    char  label;
    bool visited;
public:
    Vertex(){


    }
    Vertex(char lab){
        label=lab;
        visited=false;

    }
    };
class Graph{
private:
      const int maxvertex=20;
      Vertex* vertexlist;
      int **adj;
        int nverts;
        Stack *stack;
public:
    Graph(){
    vertexlist=new Vertex[maxvertex]; 
    adj=new int*[maxvertex];
     for (int i=0;i&lt;20;i++)
          adj[i]=new int[maxvertex];
     nverts=0;
      for (int i=0;i&lt;maxvertex;i++){
           for (int j=0;j&lt;maxvertex;j++){
               adj[i][j]=0;
           }
           }

         stack=new Stack();
    }
    void add(char lab){

        vertexlist[nverts++]=new Vertex(lab);
    }1




};
int main(){








    return 0;
}
</code></pre>

<p>Here are the compilation errors I am getting:</p>

<pre><code>&gt;   6   IntelliSense: no operator "=" matches these
&gt; operands  c:\users\datuashvili\documents\visual studio
&gt; 2010\projects\dfs\dfs\dfs.cpp 76  23  DFS     7   IntelliSense: expected a
&gt; declaration   c:\users\datuashvili\documents\visual studio
&gt; 2010\projects\dfs\dfs\dfs.cpp 77  3   DFS Error   1   error C2864:
&gt; 'Stack::size' : only static const integral data members can be
&gt; initialized within a class    c:\users\datuashvili\documents\visual
&gt; studio 2010\projects\dfs\dfs\dfs.cpp  8   1   DFS Error   3   error C2864:
&gt; 'Graph::maxvertex' : only static const integral data members can be
&gt; initialized within a class    c:\users\datuashvili\documents\visual
&gt; studio 2010\projects\dfs\dfs\dfs.cpp  54  1   DFS Error   2   error C2758:
&gt; 'Stack::size' : must be initialized in constructor base/member
&gt; initializer list  c:\users\datuashvili\documents\visual studio
&gt; 2010\projects\dfs\dfs\dfs.cpp 12  1   DFS Error   4   error C2758:
&gt; 'Graph::maxvertex' : must be initialized in constructor base/member
&gt; initializer list  c:\users\datuashvili\documents\visual studio
&gt; 2010\projects\dfs\dfs\dfs.cpp 60  1   DFS Error   5   error C2679: binary '='
&gt; : no operator found which takes a right-hand operand of type 'Vertex
&gt; *' (or there is no acceptable conversion) c:\users\datuashvili\documents\visual studio
&gt; 2010\projects\dfs\dfs\dfs.cpp 76  1   DFS
</code></pre>
