no writing on output file c++ : <p>a strange thing happens when i try to write on a output file:</p>

<pre><code> int main(int argc, char* argv[])
 {


  std::string outputFile = "fitness.out";
  ofstream output( outputFile.c_str() );


  FitnessFactory fitnessFactory;

  //if i write on file here it's ok

  vector&lt;string&gt; params;
  params[0]= 10;
  params[1]=120;

  //if i write on file here not ok, file empty

  Strategy* strategy = fitnessFactory.getStrategy("OneMax", params);
  vector&lt;string&gt; individual;


for(unsigned i = 0; i &lt; argc-1; i++){

string inputFile = argv[i+1];
ifstream input( inputFile.c_str() );
while( input.good() )
{
    string temp;
    input&gt;&gt;temp;
    individual.push_back(temp);
}
input.close();
// if i write on file, before call strategy-&gt;evaluate,for example
// output &lt;&lt; "hello"&lt;&lt;endl;
// file contains "hello"
string res = strategy-&gt;evaluate(individual);
//if i write here file is empty
//output&lt;&lt; res &lt;&lt; endl;
}
</code></pre>

<p>Others cpp file are: </p>

<p>factoryMethod.cpp</p>

<pre><code>      #include &lt;stdio.h&gt;
#include "strategy.cpp"
using namespace std;
class factoryMethod
{

public:
     virtual Strategy* getStrategy(string x, vector&lt;string&gt; params)    = 0;


};

 Strategy* factoryMethod :: getStrategy(string x, vector&lt;string&gt;  
 params)
{
}


class FitnessFactory : public factoryMethod
{
public:
      Strategy* getStrategy(string x, vector&lt;string&gt; params) {

        Strategy* s;

          if(x=="OneMax")
          s = new OneMax();
          else if (x=="Weierstrass") s = new Weiestrass();
          return s;
      }
};
</code></pre>

<p>strategy.cpp</p>

<pre><code>std::string Convert (float number){
std::ostringstream buff;
buff&lt;&lt;number;
return buff.str();
}

class Strategy
{
 public:
     virtual string evaluate(vector&lt;string&gt; v) = 0;
     virtual void strategy(vector&lt;string&gt; params);
 public: vector&lt;string&gt; fparams;
 };

string Strategy :: evaluate(vector&lt;string&gt; v)
{

}

void Strategy :: strategy(vector&lt;string&gt; v){
fparams = v;
}

class OneMax : public Strategy
{
public:
      string evaluate(vector&lt;string&gt; v) {
          string x = v[0];
         int count = 0;
 for (int i = 0; i &lt; x.size(); i++)
        if (x[i] == '1') count = count + 1;

            string ret = static_cast&lt;ostringstream*&gt;( &amp;   
(ostringstream() &lt;&lt; count) )-&gt;str();
            return ret;
      }
};
class Weiestrass: public Strategy
{
public:
     string evaluate(vector&lt;string&gt; v) {
  //   int repetitions = atoi( fparams[0].c_str() );
 //  int iterations = atoi( fparams[1].c_str() );
int repetitions = 10;
int iterations = 120;
vector&lt;float&gt; x;
for(int i = 0; i &lt; v.size(); i++){
    float temp = ::atof(v[i].c_str());
    x[i] = temp;
}
float fRes=0, fSum, b=2, h=0.5;

for (int j = 0; j &lt; repetitions; j++)
{

        fRes = 0;
        for (int i = 0; i &lt; x.size(); i++)
    {
            fSum=0;
            for (int k = 0; k &lt; iterations; k++) fSum += pow(b,-    
(float)k*h) * sin(pow(b,(float)k)*x[i]);
            fRes += abs(fSum);
        }
}

string s = Convert(fRes);
return s;
}
};
</code></pre>

<p>So when I try to write the result of the function or any other value after the call to evaluate the file is blank.
I do not understand why??!!</p>
