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: 2933323"] I was pondering the technique of restricting default constructor, copy constructor, assignment operator though and its validity for structs as well as classes: class A { A(); // disallow def construction A(const A&); // disallow copy construction const A& operator=(const A&); // disallow assignment public int data_member; A(int arg) : data_member(arg) {} }; struct B { B(); // disallow def construction B(const B&); // disallow copy construction const B& operator=(const B&); // disallow assignment int data_member; // public by default B(int arg) : data_member(arg) {} }; If I disallow the stuff in struct B, it acts less like a C struct, yes? John [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Default ctor, etc generated by compiler for structs?
Top