title: How can I make it impossible for my class member functions to be called in main?
body: <p>I'm writing a few classes for a homework assignment and I want it to be impossible for my class member functions to be called in main. If they are, I want the program to exit. How would I know when my member functions are being called? As for the class, each object represents a color in the format of &lt;100,200,215>. Thanks for the help!  </p>
  
  <pre><code>class Color{
  
  public:
      Color( unsigned red = 0, unsigned green = 0, unsigned blue = 0 );    //  ctor
      unsigned getRed() const;    //  accessor
      unsigned getGreen() const;    //  accessor
      unsigned getBlue() const;    //  accessor
      Color &amp; setRed( unsigned red );    //  mutator
      Color &amp; setGreen( unsigned green );    //  mutator
      Color &amp; setBlue( unsigned blue );    //  mutator
      const Color &amp; output() const;
  private:
      unsigned myRed;
      unsigned myGreen;
      unsigned myBlue;
      static unsigned okColor(unsigned color);
  
  }; //Class Color
  
  int main(int argc, const char * argv[])
  {
  
  }
  
  
  Color::Color( unsigned red, unsigned green, unsigned blue):
  myRed(okColor(red)),myGreen(okColor(green)),myBlue(okColor(blue))
  {
      //initialization list here...
  }
  
  //accessors
  unsigned Color::getRed() const {return myRed;}
  unsigned Color::getGreen() const {return myGreen;}
  unsigned Color::getBlue() const {return myBlue;}
  
  //mutators
  Color &amp; Color::setRed(unsigned red){
      myRed = okColor(red);
      return *this;
  }
  
  Color &amp; Color::setGreen(unsigned green){
      myGreen = okColor(green);
      return *this;
  }
  
  Color &amp; Color::setBlue(unsigned blue){
      myBlue = okColor(blue);
      return *this;
  }
  
  //output 
  const Color &amp; Color::output() const{
  
      cout &lt;&lt; "&lt;" &lt;&lt; myRed &lt;&lt; "," &lt;&lt; myGreen &lt;&lt; "," &lt;&lt; myBlue &lt;&lt; "&gt;" &lt;&lt; endl;
      return *this;
  }
  
  //checkers
  unsigned Color::okColor(unsigned myColor){
  
      if (myColor &gt; 255) {
          die("Color intensity is out of range!");
      }
  
      return myColor;
  }
  
  bool die(const string &amp; msg){
  
      cerr &lt;&lt; endl &lt;&lt; "Fatal error: " &lt;&lt; msg &lt;&lt;endl;
      exit(EXIT_FAILURE);
  }
  
  Color mixture( const Color &amp; color0, const Color &amp; color1, double weight){
  
      double color1Multiplier = 0;
      Color mixture;
      unsigned mixtureRed;
      unsigned mixtureBlue;
      unsigned mixtureGreen;
  
      color1Multiplier = 1 - weight;
  
      mixtureRed = (color0.getRed() * weight) + (color1.getRed() * color1Multiplier);
      mixtureBlue = (color0.getBlue() * weight) + (color1.getBlue() * color1Multiplier);
      mixtureGreen = (color0.getGreen() * weight) + (color1.getGreen() * color1Multiplier);
  
      mixture.setRed(mixtureRed);
      mixture.setBlue(mixtureBlue);
      mixture.setGreen(mixtureGreen);
  
      return mixture;
  }
  </code></pre>