|
Last change
on this file since 711 was 294, checked in by bird, 22 years ago |
|
New testcase. Fixes.
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
|
File size:
946 bytes
|
| Line | |
|---|
| 1 |
|
|---|
| 2 | class ParentClass
|
|---|
| 3 | {
|
|---|
| 4 | private:
|
|---|
| 5 | int iPrivate;
|
|---|
| 6 | static char *pszPrivateStatic;
|
|---|
| 7 |
|
|---|
| 8 | protected:
|
|---|
| 9 | int iProtected;
|
|---|
| 10 | static char *pszProtectedStatic;
|
|---|
| 11 |
|
|---|
| 12 | public:
|
|---|
| 13 | ParentClass()
|
|---|
| 14 | {
|
|---|
| 15 | iProtected = 1;
|
|---|
| 16 | iPrivate = 2;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | virtual ~ParentClass()
|
|---|
| 20 | {
|
|---|
| 21 | iProtected = -1;
|
|---|
| 22 | iPrivate = -2;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | virtual int get() const
|
|---|
| 26 | {
|
|---|
| 27 | return iProtected + iPrivate;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | virtual void set(int i)
|
|---|
| 31 | {
|
|---|
| 32 | iProtected = i;
|
|---|
| 33 | iPrivate = i + 1;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | int getPrivate(void)
|
|---|
| 37 | {
|
|---|
| 38 | return iPrivate;
|
|---|
| 39 | }
|
|---|
| 40 | };
|
|---|
| 41 | char *ParentClass::pszPrivateStatic = "PrivateStatic";
|
|---|
| 42 | char *ParentClass::pszProtectedStatic = "ProtectedStatic";
|
|---|
| 43 |
|
|---|
| 44 | class ChildClass : public ParentClass
|
|---|
| 45 | {
|
|---|
| 46 | public:
|
|---|
| 47 | ChildClass(int &ri) :
|
|---|
| 48 | ParentClass()
|
|---|
| 49 | {
|
|---|
| 50 | ri = getPrivate();
|
|---|
| 51 | }
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | int main(void)
|
|---|
| 55 | {
|
|---|
| 56 | int i;
|
|---|
| 57 | ChildClass *pObj = new ChildClass(i);
|
|---|
| 58 | pObj->set(i+1);
|
|---|
| 59 | delete pObj;
|
|---|
| 60 | return 0;
|
|---|
| 61 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.