A
andrew_nuss
Hi,
I have a simple struct:
struct Snippet {
// only data member
int* ar;
// member functions such as:
Snippet (int* array) : ar(array) {}
};
And it is the case that if I have 2 Snippets, they are the same if and
only if the "ar"
members are the same physical array pointer.
My question concerns the default == operator and != operator. Are the
sufficient to mean
"same/not same" reference to physical array? What custom operators
should I define?
main {
int ar[] = {1,2,3};
Snippet s1 = Snippet(ar);
Snippet s2 = Snippet(ar);
bool same = s1 == s2; //true???, fast???
bool diff = s1 != s2; // false???, fast???
}
Thanks,
Andy
I have a simple struct:
struct Snippet {
// only data member
int* ar;
// member functions such as:
Snippet (int* array) : ar(array) {}
};
And it is the case that if I have 2 Snippets, they are the same if and
only if the "ar"
members are the same physical array pointer.
My question concerns the default == operator and != operator. Are the
sufficient to mean
"same/not same" reference to physical array? What custom operators
should I define?
main {
int ar[] = {1,2,3};
Snippet s1 = Snippet(ar);
Snippet s2 = Snippet(ar);
bool same = s1 == s2; //true???, fast???
bool diff = s1 != s2; // false???, fast???
}
Thanks,
Andy