473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"Inheriting" during template specialisation

Hi again,

I've got another question about template specialisation. I would like
to declare some data types in the main template (the "base class") but I
would then like to extend the behaviour with template specialisations.
Unfortunately it seems that when I try this, the specialisation doesn't
get appended to the base template (as happens when you inherit from a
base class), but rather it replaces it completely, for example this code
won't compile:

template <typename T>
class A
{
public:
typedef std::vector<TV;
//V myVector; // works
};

class A<int>
{
private:
V intVector; // doesn't work
};
I get this error:

'V' is used as a type, but is not defined as a type.

Which implies that the typedef is getting lost. Is there a way around
this? Some sort of class inheritance would probably work, but I'd like
to try avoiding this as it's more for code clarity than anything else
('int' in my example above is actually a complex template instantiation,
so the code can become difficult to read if it's written out in full all
over the place.)

Thanks,
Adam.
Sep 26 '07 #1
1 1253
IMHO you have to inherit to maximize code reuse. Cannot think of any
other way...
Fair enough, that makes sense - thanks for your reply!

Cheers,
Adam.
Sep 27 '07 #2

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

Similar topics

51
by: Noam Raphael | last post by:
Hello, I thought about a new Python feature. Please tell me what you think about it. Say you want to write a base class with some unimplemented methods, that subclasses must implement (or...
11
by: Joseph Turian | last post by:
Fellow hackers, I have a class BuildNode that inherits from class Node. Similarly, I have a class BuildTree that inherits from class Tree. Tree includes a member variable: vector<Node>...
12
by: relaxedrob | last post by:
Hi All! I have a page with with the following style information: <link rel="stylesheet" type="text/css" href="/eEmployment/eTech.css" /> <style type="text/css"> DIV.Application {...
12
by: Ola Johansson | last post by:
Can anyone explain to me a meningfull use of the "new" keyword (Shadows in VB). I think i understand how it works fully but i cant figure out why you would use it. Why would you want to declare...
6
by: Jose Perez | last post by:
Dear All, We are experiencing a problem with web.config and the fact that it's settings are being "inherited" other applications. Our default website is configured to run "MyApplication1". The...
3
by: cmay | last post by:
In reading some documents from the Patterns and Practices group, I had a question about the example given for the Page Controller pattern. (I have posted the code for the BasePage below) In...
4
by: samadams_2006 | last post by:
Hello, I have a peculiar problem that I'm hoping someone can help me out with. I have a simple enough Web Application written in VB.Net via Visual Studio 2003. It simply displays a Web Form...
2
by: Christof Warlich | last post by:
Hi, I'd like to define a class that should behave as much as posible like std::string, but that has some small additional property: class ExtendedString: public std::string { public: void...
1
by: Arthur Dent | last post by:
Hello all... I have a method which returns a KeyValuePair(Of Long, String). I would like to make an alias for that, so instead of typing KeyValuePair(Of Long, String) everywhere I could just...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.