"self" constructor

Min Xu mxu@cae.wisc.edu
Wed Mar 22 17:22:00 GMT 2000


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



More information about the Gcc mailing list