Explicit copy constructor

The explicit copy constructor means that the copy constructor will not be called implicitly, which is what happens in the expression: CustomString s = CustomString(“test”); This expression literally means: create a temporary CustomString using the constructor that takes a const char*. Implicitly call the copy constructor of CustomString to copy from that temporary into s. … Read more

Can a cast operator be explicit?

Yes and No. It depends on which version of C++, you’re using. C++98 and C++03 do not support explicit type conversion operators But C++11 does. Example, struct A { //implicit conversion to int operator int() { return 100; } //explicit conversion to std::string explicit operator std::string() { return “explicit”; } }; int main() { A … Read more

Incorrectly aligned or overlapped by a non-object field error

The CF Marshaler isn’t so good at this type of thing and what you’re attempting is unsupported. The problem is that it knows that the first element is unaligned, but it seems to not understand that each element in the array would also be unaligned. You can see the behavior works in this example: [StructLayout(LayoutKind.Explicit, … Read more