Returning ifstream in a function

后端 未结 4 2144
日久生厌
日久生厌 2021-02-13 11:13

Here\'s probably a very noobish question for you: How (if at all possible) can I return an ifstream from a function?

Basically, I need to obtain the filename of a databa

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-13 11:38

    ifstream does not support copy construct semantics (that what the error message basically sais), so you cannot return an ifstream. Return an ifstream* instead, and pass to the caller the responsability to delete the allocate pointer.

提交回复
热议问题