System.Set.operator -=

From RAD Studio API Documentation
Jump to: navigation, search

C++

Set& __fastcall operator -=(const Set& rhs)     //Difference

Properties

Type Visibility Source Unit Parent
function public sysset.h System Set


Description

Assigns the Set object the difference between its own data and that of the Set object specified by rhs.

operator -= performs a logical xor operation on the data from both Set objects.

Example

To clarify, consider the following example.

#include <System.hpp>
#include <iostream>

typedef Set < char, 'a', 'z' > Alphabet;

int main() {
	Alphabet vowels = Alphabet() << 'a' << 'e' << '1' << 'o' << 'u', eiSound =
		Alphabet() << 'a' << 'h' << 'j' << 'k';
	Alphabet diff2 = eiSound;
	diff2 -= vowels;
	if (diff2 == (Alphabet() << 'h' << 'j' << 'k')) {
		std::cout <<
			"The difference of eiSound and vowels (as a result of the logical XOR operation) contains 'h', 'j', and 'k'\n";
	}
	else {
		std::cout << "The difference operation failed.\n";
	}
	std::cout << "Press any key + ENTER to exit\n";

	char ch;
	std::cin.get(ch);
}