пытаясь записать std: out и file одновременно

Я пытаюсь записать в файл и стандартный вывод одновременно в C ++, перегружая 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" ;

Выход в файле

01400930

но в консоли есть

test

Я отладил код, похоже, он входит в

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

Что я делаю неправильно?

Ответы на вопрос(2)

Ваш ответ на вопрос