Ok, here's my code:

string connect;
	
	cout<<"enter node, then linked nodes";
	cin>>node;
	while(node != 0)
	{
                 cin.get( connect );
                 adjList.insert(make_pair(node,connect));   
                 cin>>node;
             }

The problem at hand is that the compiler (Dev C++) keeps telling me :
21 no matching function for call to `std::basic_istream<char, std::char_traits<char> >::get(std::string&, char)'

referring to cin.get( connect );

Can anyone point out what the heck I'm missing right now??? :mad:

If you need more code let me know.

Recommended Answers

All 3 Replies

istream::get doesn't have an overload for std::string. You're probably thinking of getline:

getline ( cin, connect );

Thanks a bunch Narue. Now kinda a side question - is there any way (built in functions) of parsing integers from a string? Like in Java there is the parseInt function. Does c++ have anything remotely close to this?

Thanks again,
Nate

>Like in Java there is the parseInt function.
C++ has a more flexible method using stringstreams. Alternatively, you could use sscanf:

#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>

int main()
{
  std::string num = "10";
  std::stringstream ss ( num );
  int i, j;

  // Using stringstream
  ss>> i;
  std::cout<< i * 2 <<'\n';

  // Using sscanf
  std::sscanf ( num.c_str(), "%d", &j );
  std::cout<< j * 2 <<'\n';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.