source: branches/libc-0.6/testcase/456/class.cpp@ 2800

Last change on this file since 2800 was 823, checked in by bird, 22 years ago

more statics.

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 KB
Line 
1
2class ParentClass
3{
4private:
5 int iPrivate;
6 static char *pszPrivateStatic;
7
8protected:
9 int iProtected;
10 static char *pszProtectedStatic;
11
12public:
13 static char *pszPublicStatic;
14 static long lPublicStatic;
15 int iPublic;
16
17 ParentClass()
18 {
19 iPublic = 1;
20 iProtected = 2;
21 iPrivate = 3;
22 }
23
24 virtual ~ParentClass()
25 {
26 iPublic = -1;
27 iProtected = -2;
28 iPrivate = -3;
29 }
30
31 virtual int get() const
32 {
33 return iProtected + iPrivate;
34 }
35
36 virtual void set(int i)
37 {
38 iPublic = i;
39 iProtected = i + 1;
40 iPrivate = i + 2;
41 }
42
43 int getPrivate(void)
44 {
45 return iPrivate;
46 }
47};
48char *ParentClass::pszPrivateStatic = "PrivateStatic";
49char *ParentClass::pszProtectedStatic = "ProtectedStatic";
50char *ParentClass::pszPublicStatic = "PublicStatic";
51long ParentClass::lPublicStatic = 42;
52
53class ChildClass : public ParentClass
54{
55public:
56 ChildClass(int &ri) :
57 ParentClass()
58 {
59 ri = getPrivate();
60 }
61};
62
63int main(void)
64{
65 int i;
66 ChildClass *pObj = new ChildClass(i);
67 pObj->set(i+1);
68 delete pObj;
69 return 0;
70}
Note: See TracBrowser for help on using the repository browser.