1

I read that this form of getline:

getline(char *buf, streamsize num)

But I recently came across this getline function:

getline(cin,x);

where x is a string.

How is this ?

Kiril Kirov
  • 37,467
  • 22
  • 115
  • 187
program-o-steve
  • 2,630
  • 15
  • 48
  • 67
  • 2
    [Function overloading](http://www.codersource.net/c/c-tutorials/c-tutorial-function-overloading.aspx)? – Uwe Keim Jun 30 '11 at 09:38

2 Answers2

0

The first one is a member function of std::istream. And the second one is a free standalone function. You've overloaded functions for both.

Nawaz
  • 353,942
  • 115
  • 666
  • 851
0

The former is a member function of basic_istream.

The later is a free function.

Didier Trosset
  • 36,376
  • 13
  • 83
  • 122
  • 1
    @steve: A free function is a function that is not a member-function. If you do not know that, you should read a [book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Björn Pollex Jun 30 '11 at 09:43