If the issue is just that you don't want to clutter foo(), why not write the code in a separate file and #include it? So:
Code:
int foo(){
class intClass{
int a, b;
public:
intClass() {a=1; b=1;}
int doSome_over_a_b()
{
#include "intClass_doSome_over_a_b_code.cpp"
}
}
}