All pastes #987273 Raw Edit

Zeug

public text v1 · immutable
·published 2008-04-16 12:10 UTC
rendered paste body
class B {
};

class A {

public:

    void processB( B& b ) {
    }

    void processConstB( const B& b ) {
    }
};


int main( int argc, char** argv ) {

    A a;

    a.processB( B() );
    /*                                                                                                                                                       
      Gives error:                                                                                                                                           
                                                                                                                                                             
      reftest.cpp: In function 'int main(int, char**)':                                                                                                      
      reftest.cpp:21: error: no matching function for call to 'A::processB(B)'                                                                               
      reftest.cpp:9: note: candidates are: void A::processB(B&)                                                                                              
    */

    B b;
    a.processB( b ); // Works                                                                                                                                

    a.processConstB( B() ); // Works                                                                                                                         
    a.processConstB( b ); // Works                                                                                                                           

    return 0;
}