Stack Overflow Asked by UnicornButt on January 10, 2021
Class example I compiled and I’m getting this message on class human. New to oop, could someone explain why i’m getting this error and how to fix it?
#include <iostream>
#include <string>
using namespace std;
class Human
{
public:
string name;
int age;
void Introduce()
{
cout << "I am " + name << " and am ";
cout << age << " years old" << endl;
}
};
int main()
{
Human firstMan;
firstMan.name = "Adam";
firstMan.age = 30;
Human firstWomen;
firstWomen.name = "eve";
firstWomen.age = 28;
firstMan.Introduce();
firstWomen.Introduce();
}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP