473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

gcc 3.3.1 compiling - object required

ken

IN the new gcc 3.3.1 I am getting messages like these:

/data2/office/tools/bootstrp/sstring.cxx:105: error: cannot call
member function `ULONG Container::Count() const' without object

Where the Count is defined like this in the class:

using Container::Count;

So far I have worked around this by creating a member function. The
latest one was a bit above me but I ended up changing the code from:

< delete static_cast< INetContentTypeParameter * >(Remove(Count() - 1));
---
delete static_cast< INetContentTypeParameter * >(this->Remove(Count()

- 1));

This just does not make sense to me, surely the compiler should work out
that this is there. In full:

void INetContentTypeParameterList::Clear()
{
while (Count() > 0)
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() - 1));
}

Is this a compiler bug or a stronger enforcement of some standard?

KenF
Jul 19 '05 #1
5 3029
"ken" <ke*@gandalf.foskey.org> wrote...

IN the new gcc 3.3.1 I am getting messages like these:

/data2/office/tools/bootstrp/sstring.cxx:105: error: cannot call
member function `ULONG Container::Count() const' without object

Where the Count is defined like this in the class:

using Container::Count;
In which class? Does it inherit from 'Container'?
So far I have worked around this by creating a member function. The
latest one was a bit above me but I ended up changing the code from:

< delete static_cast< INetContentTypeParameter * >(Remove(Count() - 1));
---
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() - 1));


Whose member function is "Remove"?

This just does not make sense to me, surely the compiler should work out
that this is there. In full:

void INetContentTypeParameterList::Clear()
{
while (Count() > 0)
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() - 1)); }

Is this a compiler bug or a stronger enforcement of some standard?


Post more code. Preferably, in compilable form.

Victor
Jul 19 '05 #2
ken


OK now I can actually see something that might be the problem, the class I
am using is derived from List

class List : private Container
{
public:
using Container::Insert;
using Container::Replace;
using Container::Clear;
using Container::GetCurObject;
using Container::GetCurPos;
using Container::GetObject;
using Container::GetPos;
using Container::Seek;
using Container::First;
using Container::Last;
using Container::Next;
using Container::Prev;
using Container::Remove;

So the Remove is declare private by inheritance above but the using
statement is supposed to override the private to public. I added the
"using" clause at someones suggestion but it did not make any difference,
with or without the using clause.

The actual class where it is trying to be used we are seeing:

class INetContentTypeParameterList: private List

So if it is using inheritance then it should fail, but the using clause
should make that specific routine public. Is this right or wrong?

Thanks
KenF
Jul 19 '05 #3
ken
On Wed, 23 Jul 2003 09:33:24 -0400, Victor Bazarov wrote:
"ken" <ke*@gandalf.foskey.org> wrote...


OK now I can actually see something that might be the problem, the class I
am using is derived from List

class List : private Container
{
public:
using Container::Insert;
using Container::Replace;
using Container::Clear;
using Container::GetCurObject;
using Container::GetCurPos;
using Container::GetObject;
using Container::GetPos;
using Container::Seek;
using Container::First;
using Container::Last;
using Container::Next;
using Container::Prev;
using Container::Remove;

So the Remove is declare private by inheritance above but the using
statement is supposed to override the private to public.


Correct. It creates aliases for the names in 'using' declarations.
Those aliases are in 'public' area, so they are public for 'List'.
I added the
"using" clause at someones suggestion but it did not make any difference,
with or without the using clause.


It depends on what difference you thought it would make.

The actual class where it is trying to be used we are seeing:

class INetContentTypeParameterList: private List

So if it is using inheritance then it should fail, but the using clause
should make that specific routine public. Is this right or wrong?


Is what right or wront? 'List' is a private base class of 'INet...List'.
All its members, including the aliases you added to 'List' with 'using'
declarations, are private to the outside of 'INet...List'. However,
they should be visible (accessible) in the members of 'INet...List' class.

Example:

class Bottom {
public:
void foo();
protected:
void bar();
};

class Middle : private Bottom {
public:
using Bottom::bar(); // 'Middle::bar' is public
};

class Top : private Middle {
void member();
};

void Top::member() {
bar(); // this is OK -- Middle::bar is accessible here
}

int main() {
Top top;
top.bar(); // error -- anything from Middle is private
// if accessed through Top object

Middle middle;
middle.bar(); // OK -- Middle::bar is public
}

Victor


So going back to my original code:

void INetContentTypeParameterList::Clear()
{
while (Count() > 0)
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() - 1));
}
The Remove call is public from list which is in turn inherited as private
intoINetContentTypeParameterList so any routine within
INetContentTypeParameterList should be able to use Remove without any conflict.

So in this case should the compiler find the inheritance of Remove from
list and not need the explicit "this->" pointer? If I remove "this->" the
compiler is giving:

/data2/office/tools/source/fsys/dirent.cxx:347: error: cannot call member
function `??? Container::Remove()' without object

Is this a bug with gcc 3.3.1 or something else?

Ta
KenF

PS: Does anyone have a web link on the using clause searching for a
common word such as using does not work very well.
Jul 19 '05 #4
"ken" <ke*@gandalf.foskey.org> wrote...
On Wed, 23 Jul 2003 09:33:24 -0400, Victor Bazarov wrote:
"ken" <ke*@gandalf.foskey.org> wrote...


OK now I can actually see something that might be the problem, the class I am using is derived from List

class List : private Container
{
public:
using Container::Insert;
using Container::Replace;
using Container::Clear;
using Container::GetCurObject;
using Container::GetCurPos;
using Container::GetObject;
using Container::GetPos;
using Container::Seek;
using Container::First;
using Container::Last;
using Container::Next;
using Container::Prev;
using Container::Remove;

So the Remove is declare private by inheritance above but the using
statement is supposed to override the private to public.
Correct. It creates aliases for the names in 'using' declarations.
Those aliases are in 'public' area, so they are public for 'List'.
I added the
"using" clause at someones suggestion but it did not make any difference, with or without the using clause.


It depends on what difference you thought it would make.

The actual class where it is trying to be used we are seeing:

class INetContentTypeParameterList: private List

So if it is using inheritance then it should fail, but the using clause should make that specific routine public. Is this right or wrong?


Is what right or wront? 'List' is a private base class of 'INet...List'. All its members, including the aliases you added to 'List' with 'using'
declarations, are private to the outside of 'INet...List'. However,
they should be visible (accessible) in the members of 'INet...List' class.
Example:

class Bottom {
public:
void foo();
protected:
void bar();
};

class Middle : private Bottom {
public:
using Bottom::bar(); // 'Middle::bar' is public
};

class Top : private Middle {
void member();
};

void Top::member() {
bar(); // this is OK -- Middle::bar is accessible here
}

int main() {
Top top;
top.bar(); // error -- anything from Middle is private
// if accessed through Top object

Middle middle;
middle.bar(); // OK -- Middle::bar is public
}

Victor


So going back to my original code:

void INetContentTypeParameterList::Clear()
{
while (Count() > 0)
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() -

1)); }
The Remove call is public from list which is in turn inherited as private
intoINetContentTypeParameterList so any routine within
INetContentTypeParameterList should be able to use Remove without any conflict.
So in this case should the compiler find the inheritance of Remove from
list and not need the explicit "this->" pointer? If I remove "this->" the
compiler is giving:

/data2/office/tools/source/fsys/dirent.cxx:347: error: cannot call member
function `??? Container::Remove()' without object

Is this a bug with gcc 3.3.1 or something else?
I think it's a bug in gcc. Similar code:

class Contained {};

class Container {
public:
int Count();
void* Remove(int);
};

class List : private Container {
public:
using Container::Count;
using Container::Remove;
};

class INetContentTypeParameterList : private List {
public:
void Clear();
};

void INetContentTypeParameterList::Clear() {
while (Count())
delete static_cast<Contained*>(Remove(Count() - 1));
}

int main() {
INetContentTypeParameterList ilist;
ilist.Clear();
}

compiles fine with, for example, Comeau and even Visual C++ v6.

Ta
KenF

PS: Does anyone have a web link on the using clause searching for a
common word such as using does not work very well.


What do you mean? I searched Google for "using declaration" (yes,
in quotes), and got plenty of C++ links.

Victor
Jul 19 '05 #5
ken
On Wed, 23 Jul 2003 10:14:59 -0400, Victor Bazarov wrote:
compiles fine with, for example, Comeau and even Visual C++ v6.


I have raised this as a bug with gcc. Thanks for your patience.
PS: Does anyone have a web link on the using clause searching for a
common word such as using does not work very well.


What do you mean? I searched Google for "using declaration" (yes,
in quotes), and got plenty of C++ links.


It is all in the words :-)

KenF
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Martin Bless | last post by:
I need to access a MSSQL database (MS-Sql, not MySQL!)and would very much like to use mssql-0.09.tar.gz which is available from http://www.object-craft.com.au/projects/mssql/download.html ...
3
by: Ryan O'Neill | last post by:
Hi All, I am trying to deploy .aspx (asp.net) web pages to a web server without having to compile them beforehand. Using the CodeBehind approach this does not seem possible as the CodeBehind...
9
by: cppaddict | last post by:
Let's say you want to implement a Dictionary class, which contains a vector of DictionaryEntry. Assume each DictionaryEntry has two members, a word and a definition. Now assume your program...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
2
by: Keith Bottner | last post by:
I just reinstalled my system and am in the process of getting PostgreSQL up and running again. During compilation of Postgres I received the following error: .... checking for main in...
0
by: follower | last post by:
This post is mostly Google-bait for anyone else that might want to compile SpiderMonkey ( libjs / libjs.so / libjs.dylib ) for OS X (10.4.5 in my case) and then use it with Python's ctypes. I can't...
3
by: sjt003 | last post by:
I have been developing web apps in Visual Studio 2003, but since the other developers in my office don't use Visual Studio, I may have to stop too unless there is an efficient way for them to...
63
by: Kapteyn's Star | last post by:
Hi newsgroup The program here given is refused by GCC with a error i cannot understand. It says rnd00.c: In function β€˜main’: rnd00.c:26: error: expected expression before β€˜]’ token ...
3
by: thechazm | last post by:
Hello Everyone again, I have hit a brick wall and was wondering if someone could shed some light on my problem. So what I am trying to do is to create a table that stores a weekly snapshot of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.