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

Making Two Arrays Equal Each Other

I'm trying to have a getData function transfer all the objects it is holding in its array to a new array so that the new array can be used in a friend function to print the objects' information.

Expand|Select|Wrap|Line Numbers
  1. void Set::getData(Set& tempSet) const
  2. {
  3.      for (int i = 0; i < size; i++)
  4.         tempSet[i] = set[i];
  5.  
  6. }
  7.  

That code gives me this error: no match for 'operator[]' in 'tempSet[i]'

What am I doing wrong? Thanks for any help in advance.
Mar 16 '08 #1
7 12460
oler1s
671 Expert 512MB
tempSet is not an array of type Set. What are you trying to achieve by indexing it?
Mar 16 '08 #2
I'm trying to have the objects (Time objects) contained in the Set object given to another Set object. I have a function in my Time class that will print Time objects so I want to cycle through each Time object in the Set (which is an array) and print each one. To do this I need to get the objects using this getData function.
Mar 16 '08 #3
weaknessforcats
9,208 Expert Mod 8TB
Did you understand Post #2?

tempSet is a reference. That means one object. That means tempSet[i] is an error.

There is nothing in your function about Time objects.
Mar 17 '08 #4
fual
28
Did you understand Post #2?

tempSet is a reference. That means one object. That means tempSet[i] is an error.

There is nothing in your function about Time objects.
That is not necessarily true. It is a member function of Set and it would work perfectly well if Set::operator[](std::size_t) were overloaded (which is what the compiler is saying), and Set contained an array called set.
Mar 17 '08 #5
We would naturally assume that this is not the case based on what we have been shown.

Could the op please post the class header for class Set so we can properly identify the problem at hand?
Mar 17 '08 #6
We would naturally assume that this is not the case based on what we have been shown.

Could the op please post the class header for class Set so we can properly identify the problem at hand?
But my guess is that you want:

Expand|Select|Wrap|Line Numbers
  1. void Set::getData(Set& tempSet) const
  2. {
  3.   for (int i = 0; i < size; i++)
  4.     tempSet.set[i] = set[i];
  5. }
  6.  
Mar 17 '08 #7
fual
28
We would naturally assume that this is not the case based on what we have been shown.

Could the op please post the class header for class Set so we can properly identify the problem at hand?
When you say 'we,' one would naturally assume that you meant 'one' (unless you are the Queen of England, Your Majesty) ;)
Mar 17 '08 #8

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

Similar topics

2
by: M. Katz | last post by:
I'm trying to create a heirarchical linked list of sorts, and I'm looking for advice as to how best to set up the arrays. In other languages, I might use a pointer array to other pointer arrays,...
3
by: Pablo Gomes Ludermir | last post by:
Hello, I have the following case that I am trying to put in XML Schema. I have the classes HelpItem, Document and Message that work as follows: One HelpItem contains several Document and...
19
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
3
by: Naomi | last post by:
Hi there, Just wondering, if there is any way to have a dynamic / unspecified size of an array? It obviously needs to be updated, deleted etc. The only way I thought is by making the array...
0
by: Halvor Nyberg | last post by:
Situation: The server running IIS and server side asp, has access to some File servers. The clients, coming from Internet, that access the IIS server do not have access to the File servers. ...
38
by: ssg31415926 | last post by:
I need to compare two string arrays defined as string such that the two arrays are equal if the contents of the two are the same, where order doesn't matter and every element must be unique. ...
4
by: Mark Healey | last post by:
I'd like to allocate some memory for a two dimensional array. The problem is that whenever I try to use pointer arithmetic I screw up. I just want to use conventional array type statements to get...
14
by: serge calderara | last post by:
Dear all, What is the proper way to check if two object are equal ? I do not mean equal on Object type only but also object value's thnaks for help regards serge
1
by: reedr | last post by:
I'm stuck with trying to reference an array of datagridviews that i created at runtime. It works fine when I reference them within the function they were created, but now I want to refer to them in...
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...
0
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
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.