C++ std::ifstream in constructor problem

前端 未结 3 1147
忘了有多久
忘了有多久 2021-01-06 09:50

I\'ve got a problem with this code:

#include 

struct A
{   
    A(std::ifstream input)
    {
        //some actions
    }
};

int main()
{
           


        
3条回答
  •  北海茫月
    2021-01-06 10:27

    Streams are non copyable.

    So you need to pass by reference.

    struct A
    {   
        A(std::ifstream& input)
                     ^^^^^
        {
            //some actions
        }
    };
    

提交回复
热议问题