Overloading Member Functions - C++ Class

C++ examples for Class:Member Function

Description

Overloading Member Functions

class Employee { 
public: 
   // grade -- return the current grade point average 
   double grade(); 

   // grade -- set the grade and return previous value 
   double grade(double newSalary); 

}; 
class Manager { 
   public: 
     // grade -- return the percentage grade of the slope 
     double grade(); 

}; 

// grade - return the letter equivalent of a number grade 
char grade(double value); 

//... class implementation here

int main(int argcs, char* pArgs[]) 
{ 
     Employee s; 
     s.grade(3.5);        // Employee::grade(double) 
     double v = s.grade(); // Employee::grade() 

     char c = grade(v);   // ::grade(double) 

     Manager o; 
     double m = o.grade(); // Manager::grade() 
     return 0; 
}

Related Tutorials