Fast please. set default constructor

The appointment is to store ostream as a datamember and initiate it through the construct argument, and set cout as the default argument to ostream.

in print_word



using namespace std;

struct print_word
{
public:

print_word(ostream &os, const int&radlangd) : os(os) , radlangd(radlangd)
{

}
void operator() (const string& wor)
{
count+= wor.size();

if(count>=radlangd)
{
count=0;
os<<endl;
}
os<<wor<<" ";
}

private:
int count=0;
ostream &os;
int radlangd;

};
print_word(): os(std::cout) {};
Topic archived. No new replies allowed.