473,395 Members | 1,629 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,395 software developers and data experts.

private within this context ... more

I might be a little off topic but the experience level here is enough
to give me solid guidance.
So here's the code:

#ifndef FOO_TEST_H
#define FOO_TEST_H

#include <string>
#include <deque>
#include <iostream>
#include <sstream>
#include <typeinfo>
#include <cstddef>
#include <set>
#include <limits.h>

namespace foo {
class foo_test {
typedef std::deque< std::string > bucket;

bucket data;
bool bit;

void push_back ( std::string & str ) {
data.push_back( std::string() );
data.back().swap( str );
}

void mark ( void ) {
bit = true;
}

template < typename C, typename S >
struct io
{
static
foo_test & in ( foo_test & ft, S const & data )
{
std::stringstream in;
if ( in << data ) {
std::string str = in.str();
ft.push_back( str );
} else {
ft.mark();
}
return ( ft );
}
};

foo_test & operator<< ( int const & data ) {
return( io<void,int>::in( *this, data ) );
}

template < typename T >
static
void enlist ( std::string id = typeid(T).name() )
{
// stuff
}

public :
foo_test ()
: bit ( false ) {}
};
};

#endif

I'm _stuck with gcc 2.96_ for now. That said, the complaints when I
try to compile are as follows:

ccppc -g -mcpu=604 -mstrict-align -ansi -fno-builtin -I.
-IC:\Tornado2.2.1\target\h\ -DCPU
=PPC604 -DTOOL_FAMILY=gnu -DTOOL=gnu -c ..\main.cpp
In file included from ..\main.cpp:2:
...\fooTest.h: In function `static class foo::foo_test &
foo::foo_test::io<void,int>::in
(foo::foo_test &, const int &)':
...\fooTest.h:728: instantiated from here
...\fooTest.h:701: `void foo::foo_test::push_back(string &)' is private
...\fooTest.h:719: within this context
...\fooTest.h:706: `void foo::foo_test::mark()' is private
...\fooTest.h:721: within this context
...\fooTest.h:734: sorry, not implemented: `method_call_expr' not
supported by dump_expr
make: *** [main.o] Error 0x1

Done.

------------------------
offending line (1):
return( io<void,int>::in( *this, data ) );

The question: Why would the push_back and mark methods be considered
private 'in this context'?

The answer might be it's a gcc 2.96 bug but jsut wanting to ensure it's
not something I'm doing wrong.

offending line (2):
void enlist ( std::string id = typeid(T).name() )

I dont understand the 'method_call_expr' just yet but the error
"sorry, not implemented: `method_call_expr' not supported by dump_expr"
is also a mystery.

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
The work around:

1) add public before 'bucket data'.
public:
bucket data;
2)
template < typename T >
static
void enlist ( std::string id )
{
id = typeid(T).name();
// stuff
}

Workaround 2 I could live with. Workaround 1 bothers me. Ideas?

Thanks in advance

Apr 1 '06 #1
2 7871
ma740988 wrote:
I might be a little off topic but the experience level here is enough
to give me solid guidance.
Use other (newer) compilers to check your code when in doubt. It's not
a completely fool-proof method, but it often works well.
So here's the code:

#ifndef FOO_TEST_H
#define FOO_TEST_H

[...]
namespace foo {
[...]
};
The semicolon after the closing brace the defines the namespace
is the only violation of C++ rules in your code.
#endif

I'm _stuck with gcc 2.96_ for now. That said, the complaints [...]

The question: Why would the push_back and mark methods be considered
private 'in this context'?
You would have to ask g++ people.
The answer might be it's a gcc 2.96 bug but jsut wanting to ensure
it's not something I'm doing wrong.


You're not doing anything wrong *except* using a _very_old_ compiler.

V
--
Please remove capital As from my address when replying by mail
Apr 1 '06 #2


You're not doing anything wrong *except* using a _very_old_ compiler.


Appreaciate it.

Apr 1 '06 #3

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

Similar topics

3
by: Leszek Tumm | last post by:
Hi. Can you help solve a problem with operator overloading ? in one file i have definition of my class and declarations of overloaded operators: class Complex { long double Re;
6
by: Geoffrey S. Knauth | last post by:
It's been a while since I programmed in C++, and the language sure has changed. Usually I can figure out why something no longer compiles, but this time I'm stumped. A friend has a problem he...
2
by: Rob Long | last post by:
Hi there Is there any way to access private variables directly from within a priviliged function? I have a situation where the priviliged function's execution context contains variables of the...
4
by: rognon | last post by:
Hi there, I'm trying to do something, but I don't know if it's possible. Basically, I want to have a public static class method that could access a private object's method. I would like to be able...
3
by: Bmack500 | last post by:
I have a sub, and a class. The sub is like this: Sub dothis() Dim aInfoListX As New infoWrapperClass aInfoListX.params = ReadConfig() Dim sqlCMD As New SqlCommand aInfoListX.sqlCmd = sqlCMD ...
10
by: Greg | last post by:
class a { public: int x; private: int y; } class b : public a {
3
by: John Salmon | last post by:
g++ complains about illegal access to a private member when the following is compiled with a private copy constructor for the class C. When the copy constructor is public, the program runs and...
63
by: time.swift | last post by:
Coming from a C++ / C# background, the lack of emphasis on private data seems weird to me. I've often found wrapping private data useful to prevent bugs and enforce error checking.. It appears...
14
by: v4vijayakumar | last post by:
Why we need "virtual private member functions"? Why it is not an (compile time) error?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.