473,326 Members | 2,126 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,326 software developers and data experts.

what's wrong with my copy function?

my assignment was to implement a sequence class with dynamic array

for some reason the only error is this:
1>c:\documents and settings\joe\desktop\spring 2010\csc 212\hw\hw #3\sequence2.cxx(53) : error C3861: 'copy': identifier not found

^there are 3 of these since i used copy 3 times

copy is part of algorithm and i did the #include<algorithm>

ive look through this code MANY MANY times and i still cant find my mistake

please someone look through this and help me spot my possibly obvious mistake! thank you!

Expand|Select|Wrap|Line Numbers
  1.        sequence::sequence(const sequence& source)
  2.       {//copy constructor
  3.  
  4.          data = new value_type[source.capacity];
  5.          capacity = source.capacity;
  6.          used = source.used;
  7.          current_index = source.current_index;
  8.          copy(source.data, source.data + used, data);
  9.  
  10.       }
Expand|Select|Wrap|Line Numbers
  1.  void sequence::resize(size_type new_capacity)
  2.       {//changes capacity accordingly
  3.  
  4.          value_type* larger_array;
  5.  
  6.          if(new_capacity == capacity)
  7.             return;
  8.  
  9.          if(new_capacity < used)
  10.             new_capacity = used;
  11.  
  12.          larger_array = new value_type[new_capacity];
  13.          copy(data, data + used + current_index, larger_array);
  14.          delete [] data;
  15.          data = larger_array;
  16.          capacity = new_capacity;
  17.  
  18.       }
Expand|Select|Wrap|Line Numbers
  1.   void sequence::operator = (const sequence& source)
  2.       {//modify =
  3.  
  4.          value_type* new_data;
  5.  
  6.          if(this == &source)
  7.             return;
  8.  
  9.          if(capacity != source.capacity)
  10.          {
  11.             new_data = new value_type[source.capacity];
  12.             delete [] data;
  13.             data = new_data;
  14.             capacity = source.capacity;
  15.          }
  16.  
  17.          used = source.used;
  18.          current_index = source.current_index;
  19.          copy(source.data, source.data+used, data);
  20.  
  21.       }
Apr 8 '10 #1
1 1602
perhaps you should write the below line of code at the beginning:

using namespace std;
Apr 8 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Sam | last post by:
Hi I'm learning to code with C++ and wrote some very simple code. I think it's consistent with every rule but always got compiling errors that I don't understand. The code include 5 files as...
1
by: Tony Johansson | last post by:
This class template and main works perfectly fine. But could be better. I have this class template called Handle that has a pointer declared as T* body; As you can see I have a reference counter...
24
by: kalamantina | last post by:
#include "stdafx.h" #include <stdio.h> #define output( x ) printf( #x "\r\n" );fflush( stdout ) class CMyBase { public: CMyBase() { output( CMyBase() ); f(*this);
8
by: coredumperror | last post by:
Hi all you C++ gurus out there, I've got what may be an unusual question. What's the best way to get a shallow copy of a class that you've programmed to prevent accidental shallow copying? I've...
83
by: Anonymous | last post by:
Came across some code summarized as follows: char const* MyClass::errToText(int err) const { switch (err) { case 0: return "No error"; case 1: return "Not enough"; case 2: return "Too...
23
by: Jess | last post by:
Hello, I understand the default-initialization happens if we don't initialize an object explicitly. I think for an object of a class type, the value is determined by the constructor, and for...
7
by: mosfet | last post by:
HI, when trying to compile an embedded version of STL called ustl on win32 platform I get the following error : /// Returns the minimum of \p a and \p b template <typename T1, typename T2>...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
5
by: Vols | last post by:
class A{ public: int x; }; class B : public A{ public: int y; }; void foo()
16
by: John Doe | last post by:
Hi, I wrote a small class to enumerate available networks on a smartphone : class CNetwork { public: CNetwork() {}; CNetwork(CString& netName, GUID netguid): _netname(netName),...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.