Question: temp class (istream) constructor can be called by giving an input stream object but I want to called that (istream) constructor with zero argument or you can say I want to give (istream) construct a default argument. How I can do this?
#include <iostream>
class temp
{
public:
    temp(std::istream &is) { is >> i; }
private:
    int i;
};
int main()
{
    temp obj(std::cin); // okay
 /* 
  *  temp obj; // error:temp object don;t take zero argument // but i want this!
  */
}
Aucun commentaire:
Enregistrer un commentaire