472,133 Members | 1,190 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

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 1661
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.