Copy Constructor w/gcc411

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux