It seems to me that the error "no instance of overloaded function" means you have not defined the proper namespace at the beginning of the program. This could cause the 3-parameter getline() to be unknown.
getline doesn't require a using namespace std; declaration. The issue is as identified by Lerner; on line 14 you need to do
getline(inputFile, inputStream.email, ';');
and
getline(inputFile, inputStream.zip, '\n');
on line 16 to get your code to build (note the single quotes).
On another note, the stuff with the constructors isn't too difficult. If you have a struct like:
struct member
{
std::string email;
std::string zip;
};
Then the compiler will be generating a couple of constructors for you. These are special functions that get called when you first declare an instance of a class, i.e. when you do
member m;
In this case, you're not passing any arguments to the constructor. This is the default constructor. The other constructor generated by the compiler is the copy constructor, which gets used when you copy the object, obviously! Be careful though, passing an object to a function by value calls the copy constructor as well (since a copy is created to be used inside the function). OK, that's great, but where it's useful is that you can also define your own constructors, which can build your object from whatever you want it to. You can also override the compiler-generated constructors too. Infact, if you define any constructor then the compiler will not make any of the ones it would normally make, so be careful of that. So, to make a constructor for your class, you just give it a member function with the name of the class (member in this case):
struct member
{
member( const std::string& objString ); // Our new constructor
std::string email;
std::string zip;
};
To define what this new constructor does, you just do what I posted previously:
member::member( const std::string& objString )
{
std::string::size_type iPos = objString.find( ";" );
if ( iPos == std::string::npos )
throw std::invalid_argument( "Bad member string" );
this->email = objString.substr( 0, iPos );
this->zip = objString.substr( iPos + 1 );
}
You can do this anywhere below the declaration of the struct in the same file, or in another file that #includes the declaration. So, now you can build a member object from a std::string, which you may have read from a file. Excellent. Remember though, you've defined your own constructor, so the compiler won't make the ones it normally does. So, now if you do member m; anywhere in your code, you will get a compiler error. This is no problem though, you can easily make another constructor that does nothing! (you can have an unlimited number of different constructors for your class/struct)
struct member
{
member(); // A default constructor
member( const std::string& objString );
std::string email;
std::string zip;
};
And the definition of the default constructor is the simplest of all:
member::member()
{
}
And there you go, member m; will now compile fine. The default constructor doesn't have to do nothing though. You might want to know that you member object hasn't had any values put into it yet, so you could make a default constructor that sets your member variables to some known state that means they're not set:
member::member()
{
this->email = "not set";
this->zip = "not set";
}
Then if you have some code that looks like this:
member m;
std::cout << "email = " << m.email << ", zip = " << m.zip << std::endl;
You will see the result email = not set, zip = not set. Cool.
The final thing to say about constructors is a feature called an initialiser list. This is allows you to pass values to the constructors of your member variables. In the default constructor above, you can see this->email = "not set", which is setting the value of email. Anything between in the curly braces is done after the member variables have been constructed. That means we're building a std::string with it's default constructor and then throwing that default-constructed string away and then assigning the value "not set" to it. We can avoid making this intermediate string by puting the "not set" in it as it's being constructed:
member::member() : email( "not set" ), zip( "not set" )
{
}
The : email( ... part is the initialiser list. In this case it's not really an issue, but sometimes the default constructor is expensive to call, or may not exist at all.
Anyway, that's more than enough of that. Have fun and Google stuff :o)