Talk:C++ classes

message: this article needs a short section on the behavior of predefined methods and operators (copy constructor, default constructor, default destructor, assignment operator). they are non-empty methods which might affect the usage of the class, and might need to be overwritten in some cases to implement proper behavior.
also, it would help to add information about implicit constructors and the explicit keyword.  —Preceding unsigned comment added by 89.0.27.85 (talk) 19:48, 30 January 2008 (UTC)
thread_title:  predefined methods and operators 

message: The discussion of this controversy uses weasel words which weaken the argument. Deryck, can you cite sources for the two sides of this controversy? TheBoyNextDoor 01:47, 3 February 2006 (UTC)
thread_title:  Bitwise operator controversy 

message: Two of the controversies (shift operators and string operators) are really just issues with operator overloading; they're mentioned in the "Criticisms" section of that article. Also, I don't see how these "controversies" are related to structs in C++. The two I mentioned are more accurately held against operator overloading , regardless of the language. And the remaining one ("Extra keywords") is to do with C++'s syntax in general, and not any specific language feature. -- destrius 19:38, 27 March 2006 (UTC)
replies: text: It's true that they're not struct-specific. I put them there because they're controversies related to structs. --Deryck C. 14:49, 25 April 2006 (UTC)
replies: text: The "Controvercy" header should be moved to a more appropriate article as they are unrelated to the article topic. Mikademus 09:46, 14 August 2006 (UTC)
replies: text:  It's a Wiki, you just do it.  That section was utterly irrelevant to structs, and was packed with juicy weasel words.-- Rogerborg 12:21, 28 November 2006 (UTC)
thread_title:  Controversy 

message: This sentence is currently in the article:
:"The C++ struct declaration is incompatible with its C counterpart."
What is meant here? "C structs can't be used in C++", or "C++ structs can't be used in C"? I read it as the former, and I think that, while it might be technically correct, it is a misleading statement. As far as I know, the only incompability is when a C++ keyword is used as an identifier.
I think this sentence should be removed or rephrased to reflect this. Am I wrong? Ahy1 16:17, 25 April 2006 (UTC)
replies: text: You're correct, because the sentence is meant to mean the latter. I'd try to rephrase this. --Deryck C. 16:28, 26 April 2006 (UTC)
thread_title:  incompatible with C 

message: I suggest that we collaborate in rewriting the intro section to cater for the differences between "struct" and "class", and then rename the article "C++ structures and classes". The examples can be kept as class and struct works basically the same way. However, in cases which member accessibility is concerned, additional paragraphs should be added. Before, or after that, we can have a separate section on the differences between struct and class. (the language's bit clumsy here - not feeling well today) --Deryck C. 09:19, 24 October 2006 (UTC)
replies: text: Can anybody write a paragraph about public and private accessibility in this article? --Deryck C. 07:03, 30 October 2006 (UTC)
replies: text:  Remember, inheritance is different as well. -- Rogerborg 12:22, 28 November 2006 (UTC)
thread_title:  Collaboration suggestion 

message: I have removed the tag for the entire article, since the largest problem has been corrected. There's still problems in certain sub-sections, though. In particular, a lot of implementation details that vary from compiler to compiler are presented as being universally true for C++ in general. decltype 12:15, 20 January 2009 (UTC)
thread_title:  Factual accuracy 

message: I re-worded the Inheritance section, and reworked the example to make it clear that there's no guarantee on the memory layout of classes, in the general case. I left the example of how it's usually done, in the simple case, because it seems useful.
:A definite improvement. Good work! decltype (talk) 09:21, 25 September 2009 (UTC)
thread_title:  "Inheritance" section cleaned up somewhat 

message: According to the C++ standard section 9.2 (I'm reading a draft), class is declared immediately after the class-name is seen, and is considered defined after the closing brace of its class-specifier has been seen even though its member functions are in general not yet defined. That is:
 // Class declaration
 class example;
 // Class definition
 class example {
     // Member function declaration
     void member();
 };
 // Member function definition
 void example::member() {
 }
Given this, should we change declaration -> definition in section 2 of the article, as the examples there are both declarations and definitions? Kem wiki (talk) 10:20, 26 March 2010 (UTC)
thread_title:  Terminology: class declaration vs definition 

message: I learned that classes should start with uppercase characters. The examples in this text are not made according to the convention. I looked it up http://www.possibility.com/Cpp/CppCodingStandard.html#classnames and the convention is listed there. Maybe there is some other reason for the minor error, but I've adjusted the article with one sentence. Please correct me if I'm wrong.  —Preceding unsigned comment added by 92.105.153.192 (talk) 11:54, 22 June 2010 (UTC)
replies: text: The C++ Standard Library and the Standard Template Library, which usually comes with c++, follows the convention that class names consist of only lowercase characters and underscores. (For example: priority_queue) I suppose the examples follow this convention. --Bcmpinc (talk) 12:01, 4 October 2010 (UTC)

text: I agree with Bcmpinc: lowercase underscored is the standard for the STL. While many companies standardize on capitalized CammelCase for class names, it's just a convention. To my eye it is more "right" to have C++ examples on Wikipedia mirror the conventions used by the C++ standards group. —Ben FrantzDale (talk) 12:31, 4 October 2010 (UTC)
thread_title:  Class naming conventions 

message: In example it is shown that, after two char two spaces will be used for padding. And after one short int another two space will be used for padding. If we assume this argument, then structure's size will be 20 (as  1+1+2 + 2+2 +4 + 8 = 20 bytes). But it takes only 16. As we can arrange two car and one short int together to get only 4 bytes and there will be no need of padding.
So total size of structure will total up to only 16. proving no padding is used.
So, please change that example. Thank.
Attached a link to Codepad for given exapmle http://codepad.org/7BBw4pMu showing 16 as output for sizeof.  —Preceding unsigned comment added by 114.79.188.169 (talk) 06:15, 7 December 2010 (UTC)
thread_title:  Memory consumption example is wrong 

message: on the example of both struct and class, after struct person, there is a struct people. Why? This makes the two inequivalent.  —Preceding unsigned comment added by 74.192.52.24 (talk) 22:53, 4 March 2011 (UTC)
thread_title:  Why is there struct people? 

message: The article starts
<<The C++ programming language allows programmers to separate program-specific datatypes through the use of classes. Classes define types of data structures and the functions that operate on those data structures. Instances of these datatypes are known as objects and can contain  member variables, constants, member functions, and overloaded operators defined by the programmer. Syntactically, classes are extensions of the C struct, which cannot contain functions or overloaded operators.>>
The C++ standard defines an "object" as a "region of storage", not necessarily of class type.
A C++ object does not "contain"  member functions or overloaded operators.
It is not true in C++ that a `struct` cannot define functions or overloaded operators.
And so on: this article seems to be written by persons with absolutely no knowledge of C++, and no inclination to consult reference works (in particular the C++ standard).  — Preceding unsigned comment added by 138.124.86.49 (talk) 05:27, 27 August 2012 (UTC)
replies: text: And you are more than welcome to edit the article text yourself to correct perceived errors. However, I do not see a problem with the term object the way it is used in the lede. Yes, there are objects which do not have class type, but instances of classes are still objects. Objects containing member functions is definitely an inaccuracy in the article text. Regards, decltype (talk) 08:17, 28 August 2012 (UTC)
thread_title:  Needs MOD ATTENTION due to gross errors 

message: "cpp classes" should redirect to this page
Added.SDavidJacobsen (talk) 15:35, 14 September 2015 (UTC)
thread_title:  Need new redirect 

message: According to the chapter "Class Features" of the book "C++11/14 Rocks!" by Alex Korban, a type cannot be an aggregate if it has in-class initializers. This fact should be included in the section on aggregate classes. I didn't feel qualified to choose the best reference for this point and modify the existing reference link, so I'm hoping some else will do that. --AlanUS (talk) 13:56, 18 May 2016 (UTC)
thread_title:  In-class initializers not allowed in an aggregate type 

message: create two objects of the class cuboid display the surface area and volume of each 154.159.238.0 (talk) 16:18, 11 July 2021 (UTC)
thread_title:  Define a class named cuboid that stores the length, breadth and height of the cuboid and two methods that calculate and displays the surface area and the volume of the cuboid 

message: Support as per merge request @The Anome, who wrote the majority of the article. IntGrah (talk) 21:37, 30 May 2024 (UTC)
thread_title:  [[final (C++)]] should obviously be merged into this article