Solved

adding = and == to my class

Posted on 2006-06-26
2
200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

617 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