473,396 Members | 1,866 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.

contain class

Hello,
Up to now I failed to find out how I can fill a container class like
following example:
template<class T>
class field
{
explicit field(int value=0):n(value),t(new T[groesse]){}
private:
int n;
T* t;};
I need the right function and I would be glad about any example.
Jul 22 '05 #1
2 1355
jd
Le Mon, 27 Dec 2004 05:03:04 -0800, BjoernJackschina a écrit*:
Hello,
Up to now I failed to find out how I can fill a container class like
following example:
template<class T>
class field
{
explicit field(int value=0):n(value),t(new T[groesse]){}
private:
int n;
T* t;};
I need the right function and I would be glad about any example.


What do you mean ? do you want to construct such template class
(making an instance of it) ?
Or do you want to use std containers with such types ?

Jul 22 '05 #2

"BjoernJackschina" <ja*******@hotmail.com> a écrit dans le message de news:
a2**************************@posting.google.com...
Hello,
Up to now I failed to find out how I can fill a container class like
following example:
template<class T>
class field
{
explicit field(int value=0):n(value),t(new T[groesse]){}
What's "groesse"?
private:
int n;
T* t;};
I need the right function and I would be glad about any example.

std::vector< field<int> > v;

v.push_back( field<int>(10) );

You cannot have

std::vector< field > v;

because field is not a type nor a class, it is a class template. Read about
that on google (we had a discussion a couple of days ago).

Jonathan
Jul 22 '05 #3

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

Similar topics

1
by: Zeng Dinghao | last post by:
I encouter this problem. here are the sample files: //--------------- File: Bar.h ------------------------------ class Bar : public BarBase { public: void BarFunc(); // there is no BarFunc in...
2
by: Steveo | last post by:
Hi I have a form containing some text boxes and a button. I'm trying to work out how to make it so that if certain textboxes contain no data then the button is not enabled (however still...
1
by: Jim Hammond | last post by:
Does a WebControls.Image object actually contain an image, and if so, how can I get it? As far as I can tell, the WebControls.Image class does not contain the image itself. It seems to only...
14
by: WENDUM Denis 47.76.11 (agent) | last post by:
While testing recursive algoritms dealing with generic lists I stumbled on infinite loops which were triggered by the fact that (at least for my version of Pyton) characters contain themselves.See...
3
by: Rich | last post by:
I put together a simple test class libary (VB2005) with one class and one function that takes an integer argument and adds 10 the argument and returns that number. Then I created a simple VB2005...
6
by: Hubert Fritz | last post by:
Hello, I fear I want to have something which is not possible in C++. How is it possible to define a base class so that the derived class is forced to contain a static member variable, which...
2
by: J Miro | last post by:
When I call the Generic method ShowName in the following code, I get the error message "'T' does not contain a definition for 'Name'." Does anyone know why? Thanks in advance. Jay. ...
1
by: Darwin | last post by:
I am trying to register a .Net class for COM interop in VS2005. When I went to add a class there was no "COM class" as a template, so I am trying to code it myself. But I keep getting "... does not...
2
by: alastair g | last post by:
I have a generic base class and need a list to contain different types of objects that derive from this. Public class genericBase<Twhere T: ConfigBase{} I have tried :...
6
by: Author | last post by:
I have class BaseClass { public BaseClass(string s1, string s2) { this.S1 = s1; this.S2 = s2; } public string S1 { get; set;}
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.