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) 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)
"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) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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;
|
by: Tron Thomas |
last post by:
Under the right compiler the following code:
class Base
{
public:
virtual void Method(int){}
};
class Derived: public Base
{
|
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 {
|
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...
|
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;
| |
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...
|
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
|
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...
|
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.
|
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...
|
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...
| |
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,...
|
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,...
|
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...
|
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...
|
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();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |