Getline String Class problem

Joined
Mar 28, 2009
Messages
3
Reaction score
0
Hello!
I have a problem with the getline function for the string class. What I am doing is trying to pass class string member to the getline function.

something like:

Code:
#include <iostream>
#include <string>
using namespace std;

class something{
public:
string someString;
};

int main(){
something array[1000];
int i=0;

//Here is the problem...compile error
getline(cin,array[i].someString);

return 0;
}
:oops: How to pass string of a class to getline?
 
Joined
Mar 28, 2009
Messages
3
Reaction score
0
Got it! problem was inside the function (what I wrote above perfectly works in main) for function I had to pass array[1000]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top