What's the best way to do this...? (templates/inheritance problem)
&nbsp(163 Views)
I've got a big template class "A" and I want to write another template
"B" which is exactly the same as A except for one method (let's call
it "foo()").
Is there a way to do this without complete copy/paste of "A" I'd like
to do it with only one copy of the common code.
nb. foo() can't be static, it needs access to class members....
template class A {
void foo();
};
template class B {
void foo(); // I want a different "foo()" here...
};
On a related note, something which came up while I was messing around
with this is that when I inherit from a class ("A"), all the
constructors in "A" are hidden.
class A {
public:
A(int);
};
class B : public A {
public:
// Compiler writes a constructor for me, hiding A(int)...
};
main() {
// Doesn't work...compiler says 'int' can't be converted to 'const
B&'
B b(42);
}
How can I make A's constructors visible I read the faq and tried
adding
a "using A::A", but it makes no difference...
class B : public A {
public:
using A::A; // Makes no difference...
};
faq: http://www.parashift.com/c++-faq-lit....html#faq-23.9

"Zero-size" members with templates
&nbsp(78 Views)
I am trying to create "zero-sized members" of a struct. Knowing that any
freestanding object has non-zero size, I am using function typedefs for
this purpose, which works quite well as is demonstrated by the following
example code. However, ...

variadic templates - packing parameter packs?
&nbsp(138 Views)
,
I'm playing with some C++ interpreted code bindings and so far
have found variadic templates to be really helpful in making nice
wrappers for the C++ code to call into the interpreted code. However,
I haven't yet been ...

templates and their compilation
&nbsp(85 Views)
hello,
this is my first post in a newsgroup, i hope i do everything right
first of all, i am sure there have been a lot of "are templates slow"
questions around, but i think what i would like to ...

C++ "templates"
&nbsp(77 Views)
Dear,
I have been working with Perl and using templates:
http://www.template-toolkit.org/index.html
And I am interested to do it in C++. The way that I thought to do it
is to generate a grammar to parse(*) the template files and try ...

Problem with templates
&nbsp(124 Views)
Hi all,
I'm having some trouble with templates. I've read up some FAQs, but
still cannot seem to find the source of my problem!
I have three files: Bezier.h, Bezier.cpp and main.cpp.
Here are stripped down versions:
--- Bezier.h---
emplate ...

How to simulate variadic templates?
&nbsp(110 Views)
Hi all,
With a current problem, I found the variadic templates in C++0x:
http://en.wikipedia.org/wiki/C%2B%2B...adic_templates
I would need a template with variable number of parameters, but I need
them now! Is there a way to simulate this
The background:
In an ...

templates declaration and definition
&nbsp(95 Views)
,
I should separate the definition and declaration of template code. This
works fine for non-specialized templates. But I do not know how to do
this for specialized templates.
Example:
template
class C_B
{
public:
T var;
public:
C_B( ...

help with templates
&nbsp(105 Views)
,
I have a debug header (see source code below), but I'm not sure if
it's good style to have four template functions with the same code.
Could anyone advice me how to optimize that code Thank you!
#ifndef ...

Templates calling other templates?
&nbsp(111 Views)
I'm designing a protocol stack framework. In my protocol stack
framework, I have an arbitrary set of protocol stack layers that pass
data between the layers. My framework has a function like "send()" that
sends a message from the top ...

templates and friends
&nbsp(101 Views)
When making a general matrix class I came across the following
situation that I don't have an explanation for. For some friend
functions I have to declare them in advance while other works anyway.
Could anyone care to explain why ...

Are C++ templates a precompiler thing?
&nbsp(93 Views)
Well apparently not since one can step thru template code with a debugger.
But if I was willing to make the concession on debugging, templates would be
strictly a precompiler thing I have a feeling the answer I'm going to ...

virtual base functions, templates, and static functions
&nbsp(103 Views)
,
I searched for an answer to my question and found similar
posts,
but none that quite addressed the issue I am trying to resolve.
Essentially, it seems like I need something like a virtual static
function (which I know ...