Method (computer programming): Difference between revisions

Content deleted Content added
m clarify
C++Bro123 (talk | contribs)
m Operator methods: Improve C++ example
Line 108:
Operator methods [[Operator overloading|define or redefine operator symbols]] and define the operations to be performed with the symbol and the associated method parameters. C++ Example:
<syntaxhighlight lang="cpp">
#include <string>
class data
 
{
class dataData {
public:
string name;
bool operator<(const Data& data) const { return roll_ < data.roll_; }
int roll;
bool operator <bool operator==(const dataData& pdata) const {
return name_ == data.name_ && roll_ == data.roll_;
{
}
return roll < p.roll;
 
}
private:
bool operator == (const data& p) const
std::string name_;
{
int rollroll_;
return (name == p.name) and (roll == p.roll);
}
};
</syntaxhighlight>