Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Default ctor, etc generated by compiler for structs?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="JohnQ, post: 2932380"] Are a default constructor, destructor, copy constructor and assignment operator generated by the compiler for a struct if they are not explicitely defined? I think the answer is yes, because "there is no difference between a struct and a class except the public/private access specification" (and a few minor other things). When I create a class, I always start by declaring the default constructor, copy constructor and assignment operator private with no implementation. I don't do that for structs though (I consider structs like they were in C, but they really are not in the implementation as far as I know). I'm thinking that I don't handle structs the same because I trust the compiler to do the right thing in the case of structs whereas bitwise copy for a class may not be what is desired, for example. Is the above reasoning OK? Should I continue NOT declaring/defining the default stuff for structs? John [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Default ctor, etc generated by compiler for structs?
Top