top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is wrong with an object being assigned to itself?

+2 votes
256 views
What is wrong with an object being assigned to itself?
posted Mar 5, 2015 by Emran

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

A segfault occurs at runtime.

answer Mar 6, 2015 by Mohammed Hussain
Similar Questions
+2 votes

I want to use the init_priority(prio) attribute
(https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html#C_002b_002b-Attributes)

to initialize stuff in my library early so that users of the library can use the library during their own static objects construction. However, my library uses standard C++ library facilities like std::string,
std::vector, etc. The question is:

What is the lowest priority for init_priority attribute that I can use to still have libstdc++ initialize itself before my library is initialized?

+6 votes
0 votes

We define copy constructor using
A(const A & obj)

Why reference (&) is needed?
Why we are not allowed to use.

A(const A obj)
...