472,993 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 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 12419
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: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.