This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

"self" constructor


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]