// File:   02StaticVarInClass.cpp for CS319-Week 11
// Date:   April 2018
// What:   An example of a static member variable in a class

#include <iostream>
#include <string>

class Student
{
private:
  std::string name;
  static std::string university;
public:
  void set_name(std::string n) {name=n;};
  void set_university(std::string u) {university=u;};
  std::string get_name(void) {return(name);};
  std::string get_university(void) {return(university);};
};

// the static member must be initialised in global space
std::string Student::university="QCG";

int main(void)
{
  Student A, B, C;

  A.set_name("Alice Perry"); // Set the values of A.name
  std::cout << "Object A: \t\t" << A.get_name() <<
    " is a student at " << A.get_university() <<  std::endl;
   
// Set the values of B.name and B.university
  B.set_name("Breandan O hEithir"); B.set_university("UCG");
  std::cout << "Object B: \t\t" << B.get_name() <<
    " is a student at "  << B.get_university() <<  std::endl;
   
// And check the values of A again
  std::cout << "Now the data for A is : " << A.get_name() <<
    " is a student at " << A.get_university() <<  std::endl;
   
// Now set the values of C.name and C.university
  C.set_name("Olive Loughnane"); B.set_university("NUI Galway");
  std::cout << "Object C: \t\t";
  std::cout << C.get_name() << " is a student at " 
	    << C.get_university() <<  std::endl;
   
// And check the values of A one more time
  std::cout << "This time the data for A is : ";
  std::cout << A.get_name() << " is a student at " 
	    << A.get_university() <<  std::endl;
  return(0);
}
  


  
  
  
