PHP Code:
//
// main.cpp
// Test
//
// Created by Giovanni Di Grezia on 22/07/13.
// Copyright (c) 2013 Giovanni Di Grezia. All rights reserved.
//
//
//
//
// pass an external function to a class acting on a private member
#include <iostream>
#include <string>
#include <exception>
#include <cmath>
#include <iomanip>
using namespace std;
/////////////// external function
int magia_su_numero (int input){
return input *2;
}
///////////////////// test class
class test{
public:
test(int input = 1)
:numero(input)
{}
template <typename A> A do_funct (A passed_function(A) ){
return passed_function(numero);
}
private:
int numero;
};
/////////////// overloaded operator >>
int operator>> (int funct_to_pass (int ), test & target){
return ( target.do_funct(funct_to_pass) );
}
int main () {
test obj;
cout << (magia_su_numero >> obj) << endl;
return 0 ;
}