0

When I tried to input in the first name and last name in the string it, once I run it, the program only outputs the first name and does not output the second name or word.

here is my code

#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

class ClassOne
{
    public:
    void setName(string xName)
        {
            name = xName;
        }
        string getName()
        {
            return name;
        }
    private:
        string name;
};

int main()
{
    string inputName;
    cout << "Please input your name: ";
    cin >> inputName;
    ClassOne objClassOne;
    objClassOne.setName(inputName);
    cout << "Your Name is " << objClassOne.getName() << endl;
    return 0;
}

Once I input Michael Jordan it only shows Michael

I'm just a beginner in C++.

Thank you in advance!

0 Answers0