By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,929 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,929 IT Pros & Developers. It's quick & easy.

private within this context ... more

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a


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


Appreaciate it.

Apr 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.