[Mono-list] [Fwd: Sample Test]

Joe Tennies rotund@fatnsoft.com
07 Feb 2002 21:37:29 -0600


Oops.  Tried to send this w/ the wrong account.  Try this again

> I am still learning C#, so I'll submit this test in C++.  I know this
> used to fail on almost every C++ compiler (really don't know why).
> 
> int Bar()
> {
>    return 0;
> }
> 
> class cParent
> {
>    public:
>       int Bar() {return 1;}
> }
> 
> class cChild : public cParent
> {
> }
> 
> class cGrandchild : public cChild
> {
>    int Foo() {return Bar();}
> }
> 
> int main()
> {
>    cGrandhild* gcInstance = new cGrandchild();
>    
>    if (gcInstance->Foo() == gcInstance->Bar())
>       return 0;
>    else
>    {
>       cout << "Problem w/ inheritance and global functions."
>       return 1;
>    }
> }
> 
> Most C++ compilers would return gcInstance->Foo() == 0.  This means it
> would call the global instance.
> 
> I don't know if you can create a global function in C#.  If you can,
> this would be a good test to run.
>