Har hrdsmlta mellan ronen, stirrat fr lnge p skrmen. Men fr ngra felmeddelanden;
return value type does not match the function type och
too few arguments in function call - lyckas inte just nu att lsa detta. Frslag?
Kod:
**main.cpp
#include <iostream>
#include "person.hpp"
int main(void) {
/** Person class constructor. Two arguments: name and birthyear **/
// Here objects are created from the class "Person"
Person mrX("mr X", 2000);
std::cout << mrX.GetName() << " is " << mrX.GetAge(2022) << " years old." << std::endl;
}
---------------------------------------------------------
**person.hpp
#ifndef CITIZENS_CPP_PERSON
#define CITIZENS_CPP_PERSON
#include <string>
// define your Person class here
class Person { // Name of the class
public: // Access specifier
void GetName(std::string name);
void GetAge(int birthyear);
};
#endif
---------------------------------------------------------
**person.cpp
#include "person.hpp"
#include <iostream>
#include <string>
// define your Person class' functions here
void Person::GetName(std::string name) {
return name;
}
void Person::GetAge(int birthyear) {
return birthyear;
}