Originally, I have some code that looks like
class Ball
{
public:
    double x , y ;
    ofstream out ;
} ;
int main()
{
    Ball array[N] ;
    array[0].out.open("./position_1.txt") ;
    array[1].out.open("./position_2.txt") ;
    ......
}
where N is a run-time determined constant. But it suffers variable length arrays problem recently.
I try to follow the suggestion by this post Can't set variable length with variable by using STL container.
int main()
{
    vector<Ball> Balls ;
    Ball b ;
    b.out.open( "./position_1.txt" ) ;
    Balls.push_back( b ) ;
    ......
}
It fails at push_bak(), since stream can not be copied.
I can't determine the number of balls before running and I have to store the file stream instead of path for efficiency (preventing opening and closing files).
Is there any way to achieve the goal? Thanks
 
     
     
     
    