I've been programming in java and AS3 and C# for some time, and decided to give C++ a try... So, I decided to create a simple program to see how objects work here. I have two files:
Human.h
#pragma once
#include <string>
#include <iostream>
using namespace std;
class Human
{
private:
int _age;
string _name;
bool _gender;
public:
void setAge(int);
void setName(string);
int getAge();
string getName();
bool getGender();
Human(int age, string name, bool gender)
{
setAge(age);
setName(name);
_gender = gender;
}
~Human()
{
}
};
int Human::getAge(){
return _age;
}
string Human::getName(){
return _name;
}
bool Human::getGender(){
return _gender;
}
void Human::setAge(int val){
}
void Human::setName(string val){
_name = val;
}
And Main.cpp
#include <iostream>
#include "Human.h"
#include <string>
using namespace std;
void main(void){
Human *me;
me = new Human(27,"Mr Miyagi",true);
cout << "My name is "+me.getName()+" and I am "+me.getAge()+" years old";
}
What I get is a red line under the "me" word, and an error C2228: left of '.getName' must have class/struct/union