1// { dg-do assemble  }
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
11class Base
12{
13public:
14  char* getName() {return name_;}
15
16private:
17  Base();
18  Base(char* str);
19
20  char* name_;
21};
22
23class Derived : public Base
24{
25public:
26  Derived(int n, char* str);
27  Derived(int n);
28
29  int getNum() {return num_;}
30private:
31  int num_;
32};
33
34Base::Base() // { dg-error "is private" }
35{
36  name_ = std::strcpy(new char[std::strlen(" ") + 1], " ");
37}
38
39Base::Base(char* str) // { dg-error "is private" }
40{
41  if(str != NULL)
42    name_ = std::strcpy(new char[std::strlen(str) + 1], str);
43}
44
45Derived::Derived(int n, char* str) : Base(str) // { dg-error "within this context" }
46{
47  num_ = n;
48}
49
50Derived::Derived(int n) : Base() // { dg-error "within this context" }
51{
52  num_ = n;
53}
54
55
56
57int 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
67