473,499 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: Derived classes and hidden functions

Hi,

Please have a look at the following snippet:

class test_i
{
public:
virtual int myfunc () = 0;
};

template <class T>
class extra_class
{
public:
void test (int i) {}
};

template <class i, template <class> class e>
class base : public i,
public e <i>
{
};

class test_class : public base <test_i, extra_class>
{
public:
void test () {}
int myfunc ()
{
test (1);
}
};

The problem I have is, that 'test_class' actually contains the function
'test(int)' by the way it is deriving, but it gets hidden by the local
definition 'test ()'. I know I can use the 'using' keyword to unhide the
first 'test' function, but I do not know how that would look like. 'using
extra_class <test_i>::test;' does not work for me. I am using VC++ 7.1. Can
I achieve my goal at all?

Thanks in advance!
--
jb

(replace y with x if you want to reply by e-mail)
Jul 22 '05 #1
2 1193
"Jakob Bieling" <ne*****@gmy.net> wrote in message
news:ca*************@news.t-online.com
Hi,

Please have a look at the following snippet:

class test_i
{
public:
virtual int myfunc () = 0;
};

template <class T>
class extra_class
{
public:
void test (int i) {}
};

template <class i, template <class> class e>
class base : public i,
public e <i>
{
};

class test_class : public base <test_i, extra_class>
{
public:
void test () {}
int myfunc ()
{
test (1);
}
};

The problem I have is, that 'test_class' actually contains the
function 'test(int)' by the way it is deriving, but it gets hidden by
the local definition 'test ()'. I know I can use the 'using' keyword
to unhide the first 'test' function, but I do not know how that would
look like. 'using extra_class <test_i>::test;' does not work for me.
I am using VC++ 7.1. Can I achieve my goal at all?


'using extra_class <test_i>::test;' DOES work for me using VC++ 7.1. Are you
making the declaration at class scope or nested inside myfunc? It should be
at class scope. Incidentally, myfunc needs to return an int.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #2
"John Carson" <do***********@datafast.net.au> wrote in message
news:40********@usenet.per.paradox.net.au...
"Jakob Bieling" <ne*****@gmy.net> wrote in message
news:ca*************@news.t-online.com
Hi,

Please have a look at the following snippet:

class test_i
{
public:
virtual int myfunc () = 0;
};

template <class T>
class extra_class
{
public:
void test (int i) {}
};

template <class i, template <class> class e>
class base : public i,
public e <i>
{
};

class test_class : public base <test_i, extra_class>
{
public:
void test () {}
int myfunc ()
{
test (1);
}
};

The problem I have is, that 'test_class' actually contains the
function 'test(int)' by the way it is deriving, but it gets hidden by
the local definition 'test ()'. I know I can use the 'using' keyword
to unhide the first 'test' function, but I do not know how that would
look like. 'using extra_class <test_i>::test;' does not work for me.
I am using VC++ 7.1. Can I achieve my goal at all?
'using extra_class <test_i>::test;' DOES work for me using VC++ 7.1. Are

you making the declaration at class scope or nested inside myfunc? It should be at class scope. Incidentally, myfunc needs to return an int.

Hm, funny thing, now it does work indeed. Guess I misspelled it last
time I tried. And yes for the returning of int, guess I stripped down too
much of my original code :)

Thanks for the hint!
--
jb

(replace y with x if you want to reply by e-mail)
Jul 22 '05 #3

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

Similar topics

2
1974
by: Luca | last post by:
Hi, I have a quite complex question to ask you: I have defined a base class where I would like to have a map holding pointers to member functions defined in derived classes. To be more precise...
7
8641
by: Tron Thomas | last post by:
Under the right compiler the following code: class Base { public: virtual void Method(int){} }; class Derived: public Base {
9
3646
by: Daniel Kay | last post by:
Hello! I have written two template classes which implement the observerpattern in C++. I hope I manage to desribe the problem I have. template<class T> class Observer { /* ... */ }; ...
0
3318
by: Ewart MacLucas | last post by:
generated some WMI managed classes using the downloadable extensions for vs2003 from mircrosoft downloads; wrote some test code to enumerate the physicall processors and it works a treat, but a...
6
2918
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
4
1182
by: Vj | last post by:
Hi all, I am contemplating a design wherein most functions in my base class are virtual and says "request_not_supported". My derived classes override only the functions they support. In net...
4
3614
by: KishorAditya | last post by:
Hi All, Consider the following scenario: class Top { }; class Left: virtual public Top { }; class Right: virtual public Top { }; class Bottom: public Left, public Right {}; Many books propose...
12
2834
by: bgold | last post by:
Hey. I have a base class (SPRITE), and using this base class I have derived a large number of derived classes (PERSON, BULLET, MISSILE, etc.). Now, at a certain point in my program, I have a pair...
9
1937
by: fgh.vbn.rty | last post by:
Say I have a base class B and four derived classes d1, d2, d3, d4. I have three functions fx, fy, fz such that: fx should only be called by d1, d2 fy should only be called by d2, d3 fz should...
6
8132
by: Bhawna | last post by:
I am into c++ code maintenance for last 3-4 years but recently I am put into design phase of a new project. Being a small comapany I dont have enough guidance from seniors. Currently I am into a...
0
7132
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
7178
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
7223
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...
1
6899
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...
0
5475
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,...
0
3103
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...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...
1
665
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.