Hi,
I am trying to figure out why this code doesn't work when I compile it
under linux with g++
Following is the code, and the error message I get is:
main.cpp: In function âint main()â:
main.cpp:5: error: conversion from âPerson*â to non-scalar type
âPersonâ requested
I used the following command to compile: g++ Person.h Person.cpp
main.cpp
------------------------------------
//filename: Person.h
class Person
{
private:
int age;
public:
void setAge(int age);
};
--------------------------------------
//filename: Person.cpp
#include "Person.h"
void Person::setAge(int age)
{
this->age = age;
}
--------------------------------------
//filename: main.cpp
#include "Person.h"
int main()
{
Person mark = new Person();
mark.setAge(5);
return 0;
}
----------------------------------------
I am not sure what the error means, but everything looks okay to me.
Looking forward to someone helping me out on this.
Thank you!
Ali