getline none of the 2 overloads could convert all the argument types

This is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <string>

using namespace std;

string subject();

int main()
{
	cout << "question";
	getline (cin,subject);
	cout << "stuff" << subject;
}

VC++ outputs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
none of the 2 overloads could convert all the argument types
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448): could be 'std::basic_istream<_Elem,_Traits> &std::getline<char,std::char_traits<char>,std::allocator<_Ty>>(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Ax> &)'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ty=char,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(479): or       'std::basic_istream<_Elem,_Traits> &std::getline<char,std::char_traits<char>,std::allocator<_Ty>>(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Ax> &)'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ty=char,
1>              _Ax=std::allocator<char>
1>          ]
1>          while trying to match the argument list '(std::istream, overloaded-function)'
line 6 is a function declaration. Remove the ().
Oh. Thanks.

I'd rather not create another thread, so how do I stop the program closing instantly?
Last edited on
system( "pause" );

or getch( ) declared in conio.h
Topic archived. No new replies allowed.