Check out example codes for "getline cpp". It will help you in understanding the concepts better.

Code Example 1

// C++ program to demonstrate getline() function 
  
#include <iostream> 
#include <string> 
using namespace std; 
  
int main() 
{ 
    string str; 
  
    cout << "Please enter your name: \n"; 
    getline(cin, str); 
    cout << "Hello, " << str 
         << " welcome to GfG !\n"; 
  
    return 0; 
}

Code Example 2

// extract to string
#include <iostream>
#include <string>

int main ()
{
  std::string name;

  std::cout << "Please, enter your full name: ";
  std::getline (std::cin,name);
  std::cout << "Hello, " << name << "!\n";

  return 0;
}

Code Example 3

//getline allows for multi word input including spaces ex. "Jim Barens"
#include <iostream>
#include <string>

int main() 
{
  string namePerson{};     // creating string
  getline(cin, namePerson);// using getline for user input
  std::cout << namePerson; // output string namePerson
}

Learn ReactJs, React Native from akashmittal.com