473,625 Members | 3,384 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 1198
"Jakob Bieling" <ne*****@gmy.ne t> 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.par adox.net.au...
"Jakob Bieling" <ne*****@gmy.ne t> 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
1985
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 I would like my base class to have the following member: map<string, pointer_to_member_function> myClassMap;
7
8658
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
3668
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 { /* ... */ }; template<class T> classSubject {
0
3335
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 question.. The code fails with the error that: "Additional information: COM object that has been separated from its underlying RCW can not be used." if I make a call to pc.Count before iterating though the objects. Dim d As New...
6
2933
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 calling Mesh class functions. Let's say they point to each other like this: class Vertex { HalfEdge *edge; }; class HalfEdge { Vertex* vert;
4
1189
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 effect, my base class always has the sum of all the I/Fs of my derived classes. My friend disagrees with me saying that derived classes are always supposed to be "base class ++". Is there any mistake in my approach? Kindly let me know if I'm...
4
3626
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 that object of Bottom contains three vptrs, one for Left and Bottom, one for Right and one for Top. Now my question is why the compiler is storing superclasses' vptrs in
12
2854
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 of pointers, where each is a pointer to the base class (each is a SPRITE *). I know that each of these pointers actually points to one of the derived classes, even though the type of the pointer is SPRITE *, but I don't know which derived class it...
9
1944
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 only be called by d1, d3, d4 I think I have two options. (1) Make all functions virtual and define them in the required derived classes. This will of course lead to a lot of code duplication and problems in maintainability.
6
8152
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 situation where I am implementing base class functions by including a pointer to subclass member in base class. Reason being functionality is common for subclasses but the members are common within subclass only (static member of subclass) but...
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7184
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.