Constructor is private within this context for gcc 3.0.3

Jacek Sokulski jacek@lefthand.com.pl
Tue Jan 29 03:35:00 GMT 2002


I encountered a problem with private constructors in the following code:

class Input
{

public:

        explicit
        Input() {};
        Input(const char* Id) {};
        void test(const Input& xs){}
private:
        Input(const Input&);
};
int
main()
{
    Input input;
    input.test(input);// This is OK.
    input.test("abc"); // Here we have the problem!
    return 0;
}

Previous version (2.96) of gcc compiles it without problems but 3.0.3
outputs the error message:

test_gcc.cc: In function `int main()':
test_gcc.cc:11: `Input::Input(const Input&)' is private
test_gcc.cc:18: within this context
test_gcc.cc:18:   initializing argument 1 of `void Input::test(const
Input&)'
   from result of `Input::Input(const char*)'

Can anyone help me?
Jacek



More information about the Gcc-help mailing list