title: Code Error: "Is not a nonstatic data member or base class of"
body: <p>I have three classes in C++: Project, Supervisor, Date. I am trying to use composition, but the error I am encountering the following error message:</p>
  
  <pre><code>"Class Date
  
  "Date" is not a nonstatic data member or base class of class "Project"". 
  </code></pre>
  
  <p>This error occurs on this line, in Project.cpp:</p>
  
  <pre><code>Project::Project(char projectName, int sDay, int sMonth, int sYear, char supervisorName)
      : Date(sDay, sMonth, sYear), 
      : Supervisor(supervisorName)
  </code></pre>
  
  <p>Complete Code:</p>
  
  <p><strong>Date.h:</strong></p>
  
  <pre><code>#pragma once
  
  class Date
  {
  public:
      Date(int = 1, int = 1, int = 1);
      void setDate(int, int, int);
      void setDay(int);
      void setMonth(int);
      void setYear(int);
      ~Date();
  private:
      int day, month, year;
  };
  </code></pre>
  
  <p><strong>Date.cpp</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include "Date.h"
  
  Date::Date(int a, int b, int c)
  {
      setDate(a, b, c);
  }
  
  void Date::setDate(int d, int m, int y)
  {
      setDay(d);
      setMonth(m);
      setYear(y);
  }
  
  void Date::setDay(int da)
  {
      day = da;
  }
  
  void Date::setMonth(int mo)
  {
      month = mo;
  }
  
  void Date::setYear(int ye)
  {
      year = ye;
  }
  
  Date::~Date()
  {
  }
  </code></pre>
  
  <p><strong>Supervisor.h:</strong></p>
  
  <pre><code>#pragma once
  
  class Supervisor
  {
  public:
      Supervisor(char);
      ~Supervisor();
  private:
      char name;
  };
  </code></pre>
  
  <p><strong>Supervisor.cpp:</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include "Supervisor.h"
  
  
  Supervisor::Supervisor(char n)
  {
      name = n;
  }
  
  Supervisor::~Supervisor()
  {
  }
  </code></pre>
  
  <p><strong>Project.h:</strong></p>
  
  <pre><code>#pragma once
  #include "Supervisor.h"
  #include "Date.h"
  
  class Project
  {
  public:
      Project(char, int, int, int, char);
      void setProject(char, int, int, int, char);
      ~Project();
  private:
      char pname;
      Date startDate;
      Supervisor supervisor;
  };
  </code></pre>
  
  <p><strong>Project.cpp:</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include "Project.h"
  #include "Supervisor.h"
  #include "Date.h"
  
  Project::Project(char projectName, int sDay, int sMonth, int sYear, char supervisorName)
      : Date(sDay, sMonth, sYear), 
      : Supervisor(supervisorName)
  {
      setProject(projectName, sDay, sMonth, sYear, supervisorName);
  }
  
  void Project::setProject(char pN, int d, int m, int y, char sN)
  {
      pname = pN;
      startDate = (d, m, y);
      supervisor = sN;
  }
  
  Project::~Project()
  {
  }
  </code></pre>