Solved

adding = and == to my class

Posted on 2006-06-26
2
199 Views
Last Modified: 2010-04-01
I have a class thats really just a simple vector class called record that I use for a very specific function in a project I am working on, now it has a private int array value,
I want to be able to do this basically,

record a,b;
a.set(1,2,3,5);
b.set (3,2,5,1);
//where set just gives the private int array the values given as arguements
a=b;<-- this is the part I can't figure out, how do I add = to  my  list of class functions
and also
if(a==b)
 execute such and such code.

I can't find this anywhere on the internet, I believe because I don't know what to search for exactly, if anyone could help me out with this I would be greatly appreciative.
0
Comment
Question by:am3081
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16989926
Implement the operators given below

class record {
public:
      record& operator= (const record& r);
      bool operator== (const record& r);
};
0
 
LVL 12

Accepted Solution

by:
rajeev_devin earned 50 total points
ID: 16989930
record& operator= (const record& r); // assignment operator
Ex:
a=b;

bool operator== (const record& r); // equal operator
Ex:
if(a==b)
{
}
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question