OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.law/] [visibility17.C] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 305 jeremybenn
// { dg-do assemble  }
2
// GROUPS passed visibility
3
// visibility file
4
// From: Sandeep Shroff 
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 
9
#include 
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() // { dg-error "is private" }
35
{
36
  name_ = std::strcpy(new char[std::strlen(" ") + 1], " ");
37
}
38
 
39
Base::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
 
45
Derived::Derived(int n, char* str) : Base(str) // { dg-error "within this context" }
46
{
47
  num_ = n;
48
}
49
 
50
Derived::Derived(int n) : Base() // { dg-error "within this context" }
51
{
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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.