469,325 Members | 1,372 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

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

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

Jul 23 '05 #1
3 1558
Alexander Farber wrote:
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++.


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

Jul 23 '05 #2
Alexander Farber wrote:
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


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

Jul 23 '05 #3
Hi,

Rolf Magnus wrote:
Alexander Farber wrote:
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


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


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

Regards
Alex

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Anon Email | last post: by
5 posts views Thread by vilhelm.sjoberg | last post: by
2 posts views Thread by Jason Heyes | last post: by
4 posts views Thread by =?utf-8?b?QXNiasO4cm4gU8OmYsO4?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.