[ create a new paste ] login | about

Link: http://codepad.org/1iyaXVFR    [ raw code | output | fork ]

C++, pasted on Aug 22:
#include <iostream>
using namespace std;

int throw_number = 1;

void err( void )
{
    throw throw_number;
}



 
int main( void )
{
    try {
       err();
        
    } catch( int &i ) {
    	cout << "" << &i << endl;
        cout << "int &i = " << i << endl;
        i++; // constでないので、1加算できるはず!
        cout << "int &i = " << i << endl;
    }
    
    try {
       err();
        
    }  catch( const int &i ) {
    	cout << "" << &i << endl;
        cout << "const int &i = " << i << endl;
    }
}


Output:
1
2
3
4
5
0x8051488
int &i = 1
int &i = 2
0x8051488
const int &i = 1


Create a new paste based on this one


Comments: