Your code doesn't resemble
C++
'typical' one.
Try
#include<iostream>
using namespace std;
class Car
{
private:
string m_name, m_model;
int m_horsepower;
public:
Car( string name, string model, int horsepower) : m_name{name}, m_model{model}, m_horsepower{horsepower}
{
}
string details()
{
return m_name + ", " + m_model + ", " + to_string(m_horsepower);
}
};
int main()
{
string name, model;
int horsepower;
cout << "please enter car details, ";
cout << "name:";
cin >> name;
cout << "model: ";
cin >> model;
cout << "horsepower: ";
cin >> horsepower;
Car car(name, model, horsepower);
cout << "car stored details: " << car.details() << "\n";
}