473,394 Members | 1,734 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,394 software developers and data experts.

C++ Template class equivilent

I'm curious if C# has the equivalent of a template class in C++.
Where, in C++, you can do something like the following:

CList<int> myList;
CList<byte> myList;
etc.

thnx,
Chris
Nov 16 '05 #1
3 1699
On Fri, 25 Jun 2004 12:30:53 +0100, "Christoph" <jc*****@yahoo.com>
wrote:
I'm curious if C# has the equivalent of a template class in C++.


Not yet, but C# 2.0 (due in early 2005) will have generic types.
--
http://www.kynosarges.de
Nov 16 '05 #2
Not in the current version - the next version will come with "generics"
which has a lot of the C++ template functionality.

Arild

"Christoph" <jc*****@yahoo.com> wrote in message
news:O6**************@TK2MSFTNGP10.phx.gbl...
I'm curious if C# has the equivalent of a template class in C++.
Where, in C++, you can do something like the following:

CList<int> myList;
CList<byte> myList;
etc.

thnx,
Chris

Nov 16 '05 #3
Chris,

While the previous two posters are right about generics, it should be
noted that there will be a few limitations, and they are not exactly like
templates. The biggest advantage of Generics is that Generic type
definitions are created at run-time, not at compile time (unlike the C++ and
Java models) so that a List<T> is a List<T> everywhere and can be used
everywhere.

However, the major con is that you can not do something like this:

public class MyClass<T> : T
{
public void DoSomething()
{
this.CallAMethodOnT();
}
}

You can't do that kind of thing with Generics, like you could with C++
templates.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christoph" <jc*****@yahoo.com> wrote in message
news:O6**************@TK2MSFTNGP10.phx.gbl...
I'm curious if C# has the equivalent of a template class in C++.
Where, in C++, you can do something like the following:

CList<int> myList;
CList<byte> myList;
etc.

thnx,
Chris

Nov 16 '05 #4

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

Similar topics

4
by: Sebastian Faust | last post by:
Hi, I have 4 questions related to templates. I wanna do something like the following: template<typename T> class Template { public: Template_Test<T>()
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
6
by: Nobody | last post by:
This is sort of my first attempt at writing a template container class, just wanted some feedback if everything looks kosher or if there can be any improvements. This is a template class for a...
4
by: trint | last post by:
I can't find the followings equivilent: flashPlayer.Movie = Application.StartupPath + @"/Cooler2.swf"; flashPlayer.FSCommand +=new...
2
by: Rudy Ray Moore | last post by:
Whenever I get any error with Vc++7.1/.net/2003, it is followed by huge ammounts of "template assistance" error messaging referencing template code (MTL) that has nothing to do with the error. ...
3
by: Abubakar | last post by:
Hi, I have used the Monitor/manualresetevent class in .net to sycnhronize threads in C#, right now I'm programming in pure c++ and win32 and want to acheive the same functionality. Whats the...
7
by: Jon Slaughter | last post by:
I have some static fields in a class to keep track of "global" information but this information is local to each form that the class is used on. e.g., the class represents a base...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
45
by: charles.lobo | last post by:
Hi, I have recently begun using templates in C++ and have found it to be quite useful. However, hearing stories of code bloat and assorted problems I decided to write a couple of small programs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.