tentando escrever std: out e arquivo ao mesmo tempo

Eu estou tentando escrever para arquivo e stdout ao mesmo tempo dentro de c ++ sobrecarregando ofstream

test.h

 #pragma once 

#include <iostream>

using  std::ofstream;

class OutputAndConsole:public ofstream
{
public:
    std::string fileName;        
    OutputAndConsole(const std::string& fileName):ofstream(fileName),fileName(fileName){
    };
    template <typename T>
    OutputAndConsole& operator<<(T var);
};


template <typename T>
OutputAndConsole& OutputAndConsole::operator<<(T var)
{
    std::cout << var;
    ofstream::operator << (var);
    return (*this);
};

test.cpp

  OutputAndConsole file("output.txt");
  file << "test" ;

A saída no arquivo é

01400930

mas no console é

test

Eu depurei o código parece que está entrando em

_Myt& __CLR_OR_THIS_CALL operator<<(const void *_Val)

O que estou fazendo de errado?

questionAnswers(2)

yourAnswerToTheQuestion