C++ std::ifstream dans le constructeur problème

J'ai un problème avec ce code:

#include <fstream>

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

int main()
{
    std::ifstream input("somefile.xxx");

    while (input.good())
    {
        A(input);
    }

    return 0;
}

G++ sorties me présente:

$ g++ file.cpp
file.cpp: In function `int main()':
file.cpp:17: error: no matching function for call to `A::A()'
file.cpp:4: note: candidates are: A::A(const A&)
file.cpp:6: note:                 A::A(std::ifstream)

Après modification, il compiler (mais ce n'est pas résoudre le problème):

#include <fstream>

struct A
{   
    A(int a)
    {
        //some actions
    }
};

int main()
{
    std::ifstream input("dane.dat");

    while (input.good())
    {
        A(5);
    }

    return 0;
}

Quelqu'un peut-il m'expliquer quel est le problème et comment le résoudre? Merci.

OriginalL'auteur darvan | 2010-10-02