System.Set.operator -=

De RAD Studio API Documentation
Aller à : navigation, rechercher

C++

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

Propriétés

Type Visibilité  Source Unité  Parent
function public sysset.h System Set


Description

Assigne à l'objet Set la différence entre ses propres données et celles de l'objet Set spécifié par rhs.

L'opérateur -= exécute une opération logique xor sur les données des deux objets Set.

Exemple

A titre explicatif, prenons l'exemple suivant.

#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);
}