don't know what is this. las=set_difference() in c++

char *last;
char result[45];

last=set_difference(Alphabet,Alphabet+lanA,AlphaNume,AlphaNum+lanAN,result) //thus anyone know how this code work???
It gives you the set difference, from [result, last).
http://cplusplus.com/reference/algorithm/set_difference/
tnx.., but still confusing,,,
I think a quick scan through Set theory will make it more easily visualized when using those C++ set related algorithm functions easily.
can we call this code as predefined functions???
set_difference is part of the Standard C++ algorithm function so any C++ compiler vendor has to implement it so we developers can use them immediately. Hence in a way you could call set_difference as a pre-defined function ?

Please note back in C days, do you have a Standard C function to do something like set_difference ?
yups
so there that code written above will call as predefined function... Kindly please explain further about predefined functions??
E.g in C program, you use printf(...) isn't that a pre-defined function? fscanf, sscanf, fprintf etc are also pre-defined function correct ? So the concept is the same in C++. set_difference is a pre-defined function.

This website has links on all the Standard C++ functions break down into categories like Algorithm,Iterators,Containers etc.
If you want to implement a set difference algorithm, you can do something
similar to this -> http://cplusplus.com/forum/general/46495/#msg252610

Example for set1 == "abc" and set2 == "bde":

First, scan set1...

(a)bc -> counter[0]++;

a(b)c -> counter[1]++;

ab(c) -> counter[2]++;

Then, scan set2...

(b)de -> counter[1] += 2;

b(d)e -> counter[3] += 2;

bd(e) -> counter[4] += 2;

Finally, scan counter...

(only print if counter[i] == 1)

counter[0] == 1 -> print 'a'

counter[1] == 3 -> don't print 'b'

counter[2] == 1 -> print 'c'

counter[3] == 2 -> don't print 'd'

counter[4] == 2 -> don't print 'e'

Also, erasing the content of your threads after they are solved is not a good idea, as
other people might find them useful -> http://cplusplus.com/forum/general/46373/
Last edited on
Topic archived. No new replies allowed.