OSDN Git Service

PR c++/4872
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.law / visibility17.C
1 // Build don't link: 
2 // GROUPS passed visibility
3 // visibility file
4 // From: Sandeep Shroff <ss@caere.com>
5 // Date:     Thu, 05 Aug 1993 17:23:20 -0700
6 // Subject:  Access to private constructor.
7 // Message-ID: <9308060023.AA10283@neptune.caere.com>
8 #include <iostream>
9 #include <cstring>
10
11 class Base
12 {
13 public:
14   char* getName() {return name_;}
15
16 private:
17   Base();
18   Base(char* str);
19
20   char* name_;
21 };
22
23 class Derived : public Base
24 {
25 public:
26   Derived(int n, char* str);
27   Derived(int n);
28
29   int getNum() {return num_;}
30 private:
31   int num_;
32 };
33
34 Base::Base()
35 { // ERROR - private
36   name_ = std::strcpy(new char[std::strlen(" ") + 1], " ");
37 }
38
39 Base::Base(char* str)
40 { // ERROR - private
41   if(str != NULL)
42     name_ = std::strcpy(new char[std::strlen(str) + 1], str);
43 }
44
45 Derived::Derived(int n, char* str) : Base(str)
46 {// ERROR - .*
47   num_ = n;
48 }
49
50 Derived::Derived(int n) : Base()
51 {// ERROR - .*
52   num_ = n;
53 }
54
55
56
57 int main()
58 {
59   // Derived* d = new Derived(10, "test");
60   Derived* d = new Derived(10);
61
62   std::cerr << d->getNum() << "\t" << d->getName() << std::endl;
63 }
64
65
66