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

copy constructor

Hi all,

I need to make a copy constructor for a collection class:
public class KeywordCollection : BindingList<BaseKeyword>
{}

Class KeywordCollection is nothing more than a BindingList of
BaseKeywod.

I just don't see how I can make a copyconstructor in the
KeywordCollection class.
eg: KeywordCollection keywordsNew = new KeywordCollection(keywordOld)

I hope somone can help.

Regards,
Stijn

Sep 20 '07 #1
2 1224
Tarscher,

You have to do it yourself, like so:

public class KeywordCollection : BindingList<BaseKeyword>
{
public KeywordCollection(KeywordCollection toCopy)
{
// Copy here.
}
}

However, given that this doesn't have the same semantics in .NET as it
did in C++, you might want to look into implementing the IClonable interface
instead.

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

"Tarscher" <ta******@gmail.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...
Hi all,

I need to make a copy constructor for a collection class:
public class KeywordCollection : BindingList<BaseKeyword>
{}

Class KeywordCollection is nothing more than a BindingList of
BaseKeywod.

I just don't see how I can make a copyconstructor in the
KeywordCollection class.
eg: KeywordCollection keywordsNew = new KeywordCollection(keywordOld)

I hope somone can help.

Regards,
Stijn
Sep 20 '07 #2

"Tarscher" <ta******@gmail.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...
Hi all,

I need to make a copy constructor for a collection class:
public class KeywordCollection : BindingList<BaseKeyword>
{}

Class KeywordCollection is nothing more than a BindingList of
BaseKeywod.

I just don't see how I can make a copyconstructor in the
KeywordCollection class.
eg: KeywordCollection keywordsNew = new KeywordCollection(keywordOld)

I hope somone can help.

Regards,
Stijn

Sep 20 '07 #3

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

Similar topics

42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
15
by: A | last post by:
Hi, A default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including...
8
by: Jesper | last post by:
Hi, Does the concept "copy constructor" from c++ excist in c#. What is the syntax. best regards Jesper.
10
by: utab | last post by:
Dear all, So passing and returning a class object is the time when to include the definition of the copy constructor into the class definition. But if we don't call by value or return by value, ...
8
by: shuisheng | last post by:
Dear All, I am wondering how the default copy constructor of a derived class looks like. Does it look like class B : public A { B(const B& right) : A(right) {}
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
9
by: puzzlecracker | last post by:
From my understanding, if you declare any sort of constructors, (excluding copy ctor), the default will not be included by default. Is this correct? class Foo{ public: Foo(int); // no...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.