System.Set.operator -
C++
Set __fastcall operator -(const Set& rhs) const //Difference
Propriétés
Type | Visibilité | Source | Unité | Parent |
---|---|---|---|---|
function | public | sysset.h | System | Set |
Description
Renvoie un nouvel objet Set qui est la différence entre deux objets Set.
L'opérateur - renvoie l'ensemble d'éléments des instances Set qui ne sont pas aussi éléments de l'ensemble spécifié par rhs.
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 diff1 = vowels - eiSound;
if (diff1 == (Alphabet() << 'e' << '1' << 'o' << 'u')) {
std::cout <<
"The difference of vowels and eiSound contains 'e', '1', 'o', and 'u''\n";
}
else {
std::cout << "The difference operation failed.\n";
}
std::cout << "Press any key + ENTER to exit\n";
char ch;
std::cin.get(ch);
}