How to pass reference of ifstream to function that expects istream

I have a Lexer class, and one of its members is an istream reference. I chose to make it an istream in order to support any kind of input streams that inherit from it - standard input, files, etc..
So Lexer's constructor takes an istream& and initializes the member to that:
1
2
Lexer::Lexer(std::istream& _codeStream) :
codeStream(_codeStream) {}

In my main function, I create a new ifstream object, and I want to pass its reference to Lexer's constructor, but I can't seem to get it to work. How would I go about doing this?
Just pass it. An ifstream is an istream. There shouldn't be a problem.
Ah, you're right. It seems that Visual Studio was just highlighting the first argument as an error, but after building it there was another separate problem entirely.
Topic archived. No new replies allowed.