This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
"self" constructor
- To: gcc at gcc dot gnu dot org
- Subject: "self" constructor
- From: Min Xu <mxu at cae dot wisc dot edu>
- Date: Wed, 22 Mar 2000 19:22:18 -0600
- Reply-To: mxu at cae dot wisc dot edu
Hi all,
I used to be a java programmer before I recently graduated into c++. I
have a question about calling a constructor of a class from another
constructor of this class. I already searched the archives of this
mailing
list, however, I can't find answers about it.
My question in detail is that why following code is rejected by gcc?
(my version is 2.95.2)
// test class for "self" constructor
class test {
private:
int i;
int j;
public:
test(int ii):i(ii) {};
test(int ii, int jj):test(ii), j(jj) {};
}
I know this code is too much java-like, but my point is why it is
disallowed?
I guest "super()" isn't in c++ is because c++ has multi-inheritance. But
why not
"this()"?
Thank you for your attention for reading my question.
Min