Is Private Within This Context C

Is Private Within This Context C




๐Ÿ’ฃ ๐Ÿ‘‰๐Ÿป๐Ÿ‘‰๐Ÿป๐Ÿ‘‰๐Ÿป ALL INFORMATION CLICK HERE ๐Ÿ‘ˆ๐Ÿป๐Ÿ‘ˆ๐Ÿป๐Ÿ‘ˆ๐Ÿป




















































This website uses cookies. By continuing, you give permission to deploy cookies, as detailed in our privacy policy. ok
Forum
Beginners
Inheritance and "private within context"
class Worker
{
public :
Position p;
double salary;
...
private :
....
};

class Employee : public Worker
{
public :
...
private :
...
};
class Worker
{
public :
enum Position { EMPLOYEE, BOSS };
Worker(Position p) : p(p) {}
private :
Position p;
double salary;
};

class Employee : public Worker
{
public :
Employee() : Worker(EMPLOYEE) {}
private :
};

int main()
{
Employee e;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

class Worker
{
private: // implicit here, but stated for clarity
Position p;
double salary;
...
public:
Worker (Position pos, double sal)
{ p = pos; salary = sal; } // Initialize Worker's private members
};

class Employee : public Worker
{
public :
Employee (Position pos, double sal);
...
private :
...
};

...
// Create an employee
Employee * emp;
emp = new Employee(worker, 10.00);


Topic archived. No new replies allowed.
Home page | Privacy policy
ยฉ cplusplus.com, 2000-2021 - All rights reserved - v3.2
Spotted an error? contact us

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
#include
#include
#include
#include
#include
#include
#include

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::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::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::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


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




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


Appreaciate it.


Replies have been disabled for this discussion.
3 posts views Thread by Leszek Tumm | last post: by

6 posts views Thread by Geoffrey S. Knauth | last post: by

2 posts views Thread by Rob Long | last post: by

4 posts views Thread by rognon | last post: by

3 posts views Thread by Bmack500 | last post: by

10 posts views Thread by Greg | last post: by

3 posts views Thread by John Salmon | last post: by

63 posts views Thread by time.swift | last post: by

14 posts views Thread by v4vijayakumar | last post: by

reply views Thread by PrototypeChain | last post: by

reply views Thread by dreamtext | last post: by

reply views Thread by coodingd | last post: by

reply views Thread by ioana budai | last post: by

reply views Thread by zhoujie | last post: by

4 posts views Thread by HopkinsUni | last post: by

1 post views Thread by UniDue | last post: by

reply views Thread by amitsingh07s | last post: by

reply views Thread by Randomdude12 | last post: by


Follow us! Get the Latest Bytes Updates
By using this site, you agree to our Privacy Policy and Terms of Use.

Twinks Boys Pics
Sexy Lesbian In Fnaf
Sweet Teen Models
Pet Slut Xxx
Porno Lesbian Video 2021
private within this context, the mind of man is surely not ...
private within this context ... more - C / C++
c++ - ะ”ะพัั‚ัƒะฟ ะบ ะฟั€ะธะฒะฐั‚ัƒ ั‡ะตั€ะตะท friend - Stack Overflow ะฝะฐ ...
is private within this context_ไบ‹่‹ฅๆฑ‚ๅ…จไฝ•ๆ‰€ไน๏ผŸ ไธ–้—ดๅฅฝ็‰ฉไธๅš็‰ข๏ผŒๅฝฉไบ‘ๆ˜“ๆ•ฃ็‰ โ€ฆ
c++ - is inaccessible within this context - Stack Overflow ...
derrick - c++/10854: "XXX is private within this context ...
ะšะพะณะดะฐ ั‡ะฐัั‚ะฝั‹ะน ะบะพะฝัั‚ั€ัƒะบั‚ะพั€ ะฝะต ัะฒะปัะตั‚ัั ั‡ะฐัั‚ะฝั‹ะผ ะบะพะฝัั‚ั€ัƒะบั‚ะพั€โ€ฆ
Fix Within This Context Error Tutorial - usedtech.org
Is Private Within This Context C


Report Page