Advertisement

04.10.2008 at 09:50AM PDT, ID: 23312484
[x]
Attachment Details

Vector copy constructor

Asked by Ennio in C++ Programming Language, Programming Languages

Tags: C++

I'm creating my own vector class and I just finished my copy constructor, and I would like to see if I'm missing anything.

Here is the code. From what I've been reading on the book , looks like this is complete, but it's always good to get some other advices.

thanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
vector::vector(const vector & obj)
{
                     vector temp(obj.cap);
	for ( int i = 0; i < obj.nvalid; i++){
		temp.ptr[i] = obj.ptr[i];
	}
	nvalid = obj.nvalid;
}
[+][-]04.10.2008 at 10:02AM PDT, ID: 21326958

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C++ Programming Language, Programming Languages
Tags: C++
Sign Up Now!
Solution Provided By: lucky_james
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.10.2008 at 10:05AM PDT, ID: 21326995

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 10:06AM PDT, ID: 21327004

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 10:07AM PDT, ID: 21327016

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628