Iget following error on code below, but can't understand what's wrong as I tried similar case and it works, could someone help me?
24|error: ISO C++ forbids declaration of ‘Pogrammer’ with no type [-fpermissive]|
In member function ‘int Programmer::Pogrammer(int, std::__cxx11::string, std::__cxx11::string)’:|
25|error: only constructors take member initializers|
25|error: expected primary-expression before ‘int’|
25|error: expected primary-expression before ‘name’|
27|warning: no return statement in function returning non-void [-Wreturn-type]|
|In function ‘int main()’:|
35|error: no matching function for call to ‘Programmer::Programmer(int, const char [5], const char [4])’|
/19|note: candidate: Programmer::Programmer(const Programmer&)|
19|note: candidate expects 1 argument, 3 provided|
19|note: candidate: Programmer::Programmer(Programmer&&)|
19|note: candidate expects 1 argument, 3 provided|
||=== Build failed: 5 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
#include <string>
class Person{
private:
int m_age;
std::string m_name;
public:
Person(int age, std::string name):
m_age(age), m_name(name)
{
}
int getAge() const {return m_age;}
};
class Programmer: public Person{
private:
std::string m_lang;
public:
Pogrammer(int age, std::string name, std::string lang):
Person(age, name), m_lang(lang)
{
}
std::string getLang() const {return m_lang;}
};
int main(){
Programmer john(22, "John", "C++");
return 0;
}
|