473,549 Members | 5,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

declaration of `const AreaSet &CObeyFile::Are aSet () 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::Are aSet () 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 1841
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::Are aSet () 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::Are aSet () 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::Are aSet () 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1581
by: Anon Email | last post by:
Hey people, This looks really weird. I can't make sense of it. Is this a mistake? Can anyone help? IStack const & GetStack () const; Cheers,
1
2149
by: elviin | last post by:
Hello. I'd like to know what means const() in the following declaration T & operator(std::ptrdiff_t i) const() const; I've been looking on http://boost.org/libs/smart_ptr/shared_array.htm
6
9736
by: kelvSYC | last post by:
This little bit of seeminly innocent code seems to give me these two errors, all on the line that declares check(). Is there some part of C++ that I'm missing out on? class Condition { public: Condition() {} virtual ~Condition() {} virtual bool check() const;
5
7210
by: vilhelm.sjoberg | last post by:
Hello, I am a resonably confident C programmer, but not very sure about the dark corners of C++. Recently, I had G++ give me a strange error. The program in question is in essence: struct foo { };
18
1593
by: hzmonte | last post by:
typedef int t_compare_func(const void *, const void *); struct node *tree_search(struct node *root, const void *keyy, t_compare_func *comp) { struct node *cur_item; int result; if (root == NULL) return NULL; cur_item = root; while (cur_item != NULL) {
2
4982
by: Alex Sedow | last post by:
Why interface-event-declaration does not support multiple declarators like event-declaration? Grammar from C# spec: variable-declarators: variable-declarator variable-declarators "," variable-declarator variable-declarator:
2
1562
by: Jason Heyes | last post by:
Are these two lines equivalent? const int x = 3; const x = 3; Thanks.
5
3730
by: Owen Ransen | last post by:
When I installed the new VC 2005 I though, aha at last I will be able initialise static const members in the H file, and I can, but only integer types. double types have to be declared in the H file but initialied in the CPP file. It seems that MS is following the standard this time, but why is there that rule?
4
1907
by: =?utf-8?b?QXNiasO4cm4gU8OmYsO4?= | last post by:
Suppose I have a function that takes a pointer as its input, but does not change what the pointer points to. In that case, the const qualifier can be used to indicate that the variable pointed to is not changed. But should this const qualifier be used in the function declaration, the function definition, or both? Example: In .h-file...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7723
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7962
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7814
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.