![]() |
|
#1
|
|||
|
|||
Comparing two arraysHello guys,
I am using Visual C++ 6.0. I have a vector of array. Each element of the vector contains an array [25]. I have a button on my dialog window which call a save function to to save the array in the vector. I want to add a function to check the changes made to the array and pop up a message if the user forget to save changes. I want save a copy of the array at the start and use that array to check for any changes made. That is, compare the copy and the main array. Code:
But unfortunately I get the following error messages: error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'struct Face' (or there is no acceptable conversion) error C2678: binary '!=' : no operator defined which takes a left-hand operand of type 'struct Face' (or there is no acceptable conversion) I have included the following header Code:
Can anyone please advise on what I'm doing wrong. Thank you very in advance... |
|
#2
|
|||
|
|||
|
Well, i think your problem is here:
if (FaceCopy == FaceFeat) and if (FaceCopy != FaceFeat) specifically in the comparations "FaceCopy == FaceFeat", "FaceCopy != FaceFeat"... Its because you cant compare two different arrays or structures like that, you would have to do comparison comparind their elements one by one... The "==" operator doesnt accepts structures or arrays because they may contain many elements and it only compares between pairs of simple elements... so thats why the compiler says: error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'struct Face' (or there is no acceptable conversion) error C2678: binary '!=' : no operator defined which takes a left-hand operand of type 'struct Face' (or there is no acceptable conversion) |
|
#3
|
|||
|
|||
|
You're not making copies or comparing them properly. Your copy loop:
CPP / C++ / C Code:
FaceCopy = Feat[0]; FaceCopy = Feat[1]; FaceCopy = Feat[2]; FaceCopy = Feat[3]; ... i.e. it's overwriting whatever value is placed in FaceCopy. So all it ends up with the last value in the object Feat. Similarily for the second loop. Also then after, are you sure you wish to use the iterative indices i & j outside the scope of their loops? Whatever types FaceCopy & FaceFeat are, there is no comparison operators defined. Are they objects? If so you can create them as follows (C++ only): CPP / C++ / C Code:
GF |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problems with 2d arrays.. | mgdpetter | C Programming Language | 12 | 27-May-2004 21:45 |
| need help with passing 3 arrays into a function | tommy69 | C Programming Language | 14 | 07-Apr-2004 01:22 |
| help on comparing structs | nusstu | C Programming Language | 4 | 03-Apr-2004 03:22 |
| Problem multiplying arrays | hellhammer | C Programming Language | 9 | 29-Mar-2004 16:32 |
| pointers and arrays | jack | C Programming Language | 4 | 15-Jan-2004 13:27 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The