Connecting Tech Pros Worldwide Forums | Help | Site Map

declaration of `const AreaSet &CObeyFile::AreaSet () Declaration of "const A &B::A() const" changes meaning of A from "class A"

Alexander Farber
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi,

does anyone have an idea, why do I get the following error
(I have to use g++296 on RedHat Linux as compiler):

In file included from r_dir.cpp:9:
r_obey.h:262: declaration of
`const AreaSet &CObeyFile::AreaSet () const'
r_areaset.h:197: changes meaning of `AreaSet' from `class AreaSet'

The afore-mentioned line in r_obey.h is:

class CObeyFile
{
private:
AreaSet iAreaSet;

public:
const AreaSet& AreaSet() const; // line 262

And the line in r_areaset.h is:

class AreaSet
{ // line 197
public:
AreaSet();
~AreaSet();

Same code compiles fine with MS VC++.

Thank you for any hints!
Alex


Kristo
Guest
 
Posts: n/a
#2: Jul 23 '05

re: declaration of `const AreaSet &CObeyFile::AreaSet () Declaration of "const A &B::A() const" changes meaning of A from "class A"


Alexander Farber wrote:[color=blue]
> Hi,
>
> does anyone have an idea, why do I get the following error
> (I have to use g++296 on RedHat Linux as compiler):
>
> In file included from r_dir.cpp:9:
> r_obey.h:262: declaration of
> `const AreaSet &CObeyFile::AreaSet () const'
> r_areaset.h:197: changes meaning of `AreaSet' from `class AreaSet'
>
> The afore-mentioned line in r_obey.h is:
>
> class CObeyFile
> {
> private:
> AreaSet iAreaSet;
>
> public:
> const AreaSet& AreaSet() const; // line 262
>
> And the line in r_areaset.h is:
>
> class AreaSet
> { // line 197
> public:
> AreaSet();
> ~AreaSet();
>
> Same code compiles fine with MS VC++.[/color]

Well, in r_areaset.h, 'AreaSet' is a class. Then, in r_obey.h, you try
to redeclare it as a function. You can't do that. The easy solution
is to rename the function to something like GetAreaSet().

Kristo

Rolf Magnus
Guest
 
Posts: n/a
#3: Jul 23 '05

re: declaration of `const AreaSet &CObeyFile::AreaSet () Declaration of "const A &B::A() const" changes meaning of A from "class A"


Alexander Farber wrote:
[color=blue]
> Hi,
>
> does anyone have an idea, why do I get the following error
> (I have to use g++296 on RedHat Linux as compiler):
>
> In file included from r_dir.cpp:9:
> r_obey.h:262: declaration of
> `const AreaSet &CObeyFile::AreaSet () const'
> r_areaset.h:197: changes meaning of `AreaSet' from `class AreaSet'
>
> The afore-mentioned line in r_obey.h is:
>
> class CObeyFile
> {
> private:
> AreaSet iAreaSet;
>
> public:
> const AreaSet& AreaSet() const; // line 262[/color]

Your function is called AreaSet, just the same as the class.

Alexander Farber
Guest
 
Posts: n/a
#4: Jul 23 '05

re: declaration of `const AreaSet &CObeyFile::AreaSet () Declaration of "const A &B::A() const" changes meaning of A from "class A"


Hi,

Rolf Magnus wrote:[color=blue]
> Alexander Farber wrote:[color=green]
> > In file included from r_dir.cpp:9:
> > r_obey.h:262: declaration of
> > `const AreaSet &CObeyFile::AreaSet () const'
> > r_areaset.h:197: changes meaning of `AreaSet' from `class AreaSet'
> >
> > The afore-mentioned line in r_obey.h is:
> >
> > class CObeyFile
> > {
> > private:
> > AreaSet iAreaSet;
> >
> > public:
> > const AreaSet& AreaSet() const; // line 262[/color]
>
> Your function is called AreaSet, just the same as the class.[/color]

but it is a member function (of the class CObeyFile) isn't it?
I still don't understand, why their names clash

Regards
Alex

Closed Thread