>I have used getline() but that didn't stop the compiler to get a value..
Post a full program that has the problem. I'm guessing that you have a cin>>[I]<blah>[/I] somewhere before the getline, and the getline is eating the leftover newline.
int n; // declare n of type integer
cout << " \n\n";
cout << " SET THE NUMBER OF EMPLOYEES" << endl;
cout << " --> ";
cin >> n;
// Loop until 'n' number of employees is reached //
// & Enter the data for each number of Employees //
// using the set functions //
for ( int i = 0 ; i < n ; i++ )
system("CLS"); // clear the screen
cout << "\n\n";
cout << " xxxxxxxxxxxxxxxx" << endl;
cout << " x EMPLOYEE # " << i+1 << " x" << endl;
cout << " xxxxxxxxxxxxxxxx" << "\n\n";
// Set the Name of the Employee
cout << " Enter the Name of Employee # " << i+1 << ": ";
getline ( cin, N );
myClass[i].setName( N );
Damn, I'm good. cin >> n; reads an integer, but leaves a newline on the stream. getline ( cin, N ); is supposed to stop reading when it finds a newline, so it looks like the call is getting skipped. There's a sticky thread about clearing the input stream that goes into a lot of detail about fixing the problem. But the best way to avoid it is not to use formatted input in the first place. Read everything as a string and use stringstreams (or boost::lexical_cast) to convert the string into the type you want.