user3521273
user3521273

Reputation:

C++ ifstream to function

(french, sorry 4 bad english) Hi guys, I have an error when I want send ifstream to my function.

function.cpp:

void solo(ifstream fichier)
{
    fichier("dico.txt");
}

function.h

void solo(std::ifstream fichier);

Error

Thank's !

Upvotes: 1

Views: 84

Answers (1)

Fred Larson
Fred Larson

Reputation: 62113

You're attempting to pass the stream by value, but streams cannot be copied. Pass by reference instead:

void solo(std::ifstream& fichier);

Upvotes: 5

Related Questions