how to parse using stringstream

#include <iostream>
#include <sstream>
#include <string>

int main() {
    std::string input = "John Doe 25 85.5";

    std::istringstream stream(input);

    std::string firstName, lastName;
    int age;
    double height;

    stream >> firstName >> lastName >> age >> height;

    if (stream) {
        std::cout << "Parsed successfully:\n"
                  << "First Name: " << firstName << "\n"
                  << "Last Name: " << lastName << "\n"
                  << "Age: " << age << "\n"
                  << "Height: " << height << std::endl;
    } else {
        std::cout << "Parsing failed. Invalid input." << std::endl;
    }

    return 0;
}