iostream
Ce sont des fonctions ayant le même nom mais prenant des paramètres différents
Fonctionne sur n'importe quelle fonction
#ifndef SAMPLE_CLASS_HPP # define SAMPLE_CLASS_HPP class Sample { public: Sample(void); ~Sample(void); void bar( char const c) const; void bar( int const n) const; void bar( float const z) const; void bar( Sample const & i) const; }; # endif
le fichier .cpp
#include <iostream> #include "Sample.class.hpp" Sample::Sample(void) { std::cout << "Constructor called" << std::endl; return; } Sample::~Sample(void) { std::cout << "Destructeur called" << std::endl; return; } void Sample::bar( char const c) const{ std::cout << "Member function called with char overload : " << c << std::endl; return; } void Sample::bar( int const n) const { std::cout << "Member function called with int overload : " << n << std::endl; return; } void Sample::bar( float const z) const { std::cout << "Member function called with float overload : " << z << std::endl; return; } void Sample::bar( Sample const &i) const { (void)i; std::cout << "Member function called with Sample overload" << std::endl; return; }
Constructor called Member function called with char overload : a Member function called with int overload : 42 Member function called with float overload : 3.14 Member function called with Sample overload Destructeur called