Talk:Constructor (object-oriented programming)

message: "constructor (sometimes shortened to ctor)"
In C++, a ctor is NOT a constructor.  It is one of a series of initializing expressions that are written in the header-portion of a constructor method.  They are performed, in order, before the body of the constructor is executed.   — Preceding unsigned comment added by 108.197.177.10 (talk) 00:42, 28 October 2012 (UTC)
thread_title:  This statement is inaccurate for C++ 

message: I'd rather propose to say: a constructor is an operation AND a method is an operation, too. I.E. a method may have different return types whereas a constructor's return type should be clear. You might define a constructor as a special method with a constraint about its return type but defining them as different metaclasses seems to be a better (and proper) solution.
Constructors should not be considered as a method as the declaration syntax is very different from normal methods, and it cannot be called by other methods directly (it can be called indirectly by creating a new instance object).
T4bits 15:24, 8 November 2005 (UTC)
thread_title:  Is a constructor really a method? 

message: I hope the authors realize there are more than 4 languages out there and many constructors return the object itself as a return value. Also there are no sources or citations. --Quirex 03:02, 10 December 2006 (UTC)
thread_title: Totally inaccurate and doesn't cite sources

message: This article proceeds as-if constructors are a feature peculiar to OOLs, but constructors are also a feature of functional languages, such as Haskell. — SlamDiego 05:52, 13 December 2006 (UTC)
thread_title: Functional programming

message: I have moved this section from the article as it has a number of problems that should be sorted first. The areas that could be improved are:
* use of parent/child uncommon terminology for class inheritance
* dubious programming practice in the example
* example code formatting
* code in the penultimate paragraph won't compile
Rich257 13:19, 4 January 2007 (UTC)
replies: text: In fact there is the mistaken notion that a constructor which accepts values for variables in the super-class can only set them by way of a constructor in the super-class. But otherwise hidden variables could be set by accessors in the super-class (which accessors could be hidden from all but the super-class and its sub-classes), and less hidden variables could beset more directly by the sub-class. I suggest that this whole section be discarded. — SlamDiego 02:56, 5 January 2007 (UTC)
thread_title: Constructors that use inheritence

message: Hi... Can any one tell me why virtual constructors do not exist whereas virtual destructors exist??? will be of great help.. —Preceding unsigned comment added by 210.211.241.24 (talk • contribs) 19:47, 7 May 2007
:When you are constructing an object, you know exactly what type it is (it is the type of the constructor). When you are destructing a dynamically-allocated object using the delete operator on a pointer to it, you are not necessarily sure what type the object is; because you might be using a pointer to a base class. So to call the correct destructor, the destructor needs to be virtual. --Spoon! 23:07, 17 October 2007 (UTC)
thread_title: Virtual Constructors

message: Suppose that a class is public. Does it matter whether the constructor is public or private? Sarsaparilla (talk) 00:28, 11 February 2008 (UTC)
replies: text: Of course.  It depends on the design of the class whether it has public, protected or private constructors or, possibly, a combination of these. Rich257 (talk) 08:51, 11 February 2008 (UTC)
thread_title: Public constructors vs. private constructors

message: Could some registered user please move this page to Constructor_(object-oriented_programming)? Thanks. --203.206.56.51 (talk) 12:13, 14 March 2009 (UTC)
replies: text: I agree this move should be made! I was just going to suggest it because this article is nothing more than an survey of how algebraic data type constructors are implemented in a few OO programming languages. Pcap ping 15:56, 17 August 2009 (UTC)
thread_title: Move

message: I'd to have a section on the two step constructors used in some languages like objective-c.  A quick reference: http://stackoverflow.com/questions/719877/obj-c-why-is-alloc-init-used-instead-of-new.  —Preceding unsigned comment added by 68.190.118.182 (talk) 01:26, 6 January 2010 (UTC)
thread_title:  Objective-C [class new] vs. [[class aloc] init]  

message: inside the C++ chapter, the following statement is incorrect:
 Assignments occur according to the order of the initializer list.
The correct statement is: "Assignments occur according to the order in which data members are declared (even if the order in the initializer list is different)." http://stackoverflow.com/questions/1242830/constructor-initialization-list-evaluation-order Constructor
Remark: It is good practice to list data members in the initializer list in the same order they are declared into the class (and we can get a warning from the compiler if it is not the case), so the 2 orders are usually the same.
Etienne Boireau (talk) 11:42, 12 November 2014 (UTC)
thread_title:  Incorrect statement for C++ 

message: I'm not convinced that a section on memory allocation is appropriate for this article, since constructors don't generally deal with memory allocation. Constructors are really about initialization, and allocation is a separate issue. Even if there are some languages that require a constructor to do both jobs (though I am not aware of any), this is really a quirk of the particular language and is not the norm for constructors.
Additionally, the current section on memory organization is blatantly wrong when it says that reference types are allocated on the heap while value types are allocated on the stack. Value types are allocated wherever they need to be (which may be on the stack, or may be inside another object on the heap). Additionally, even reference types can be allocated on the stack if the condition are right for certain optimizations. The real difference between reference types and value types is their semantics, not where they exist (which is why they're not called heap types and stack types).
Kwvanderlinde (talk) 04:23, 23 July 2016 (UTC)
thread_title:  Memory organization 

message: I left the following feedback for the creator/future reviewers while reviewing this article: Generally, if you have a disambiguation in an article/redirect title, you should probably use one of the disambiguation Rcats.
voorts (talk/contributions) 18:32, 12 May 2024 (UTC)
thread_title:  Feedback from New Page Review process