This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Copy Constructor w/gcc411


Hello,

I am curious, I have the test case listed which compiles fine with
gcc323 and Sun compiler 10 and 11.  The way around the gcc error is to
move the coy constructor out of private.  What am I doing wrong WRT
gcc411?  I have remarked the workaround.

[~/test]$ g++ test.c -o test
test.c: In function 'int main()':
test.c:12: error: 'A::A(const A&)' is private
test.c:21: error: within this context
[~/test]$ g++ --version
g++ (GCC) 4.1.1
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[~/test]$


TIA, Phy

[~/test}$ cat test.c
#include <iostream>
using namespace std;

class A{
public:
 A(int i){
   a = i;
 }

 //A(const A&);
private:
 A(const A&);
 int a;
};

void f(const A&){
 printf("Hello!\n");
}

int main(){
 f(A(1));
 return 0;
}


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