[Mono-list] [Fwd: Sample Test]

Piers Haken piersh@friskit.com
Fri, 8 Feb 2002 03:56:31 -0800


Joe, there's no such thing as a global function in c#. Just like in
Java, every method must be a member of a class. I guess a public static
method could be considered 'global'. I'm sure this would be a good
addition to the Mono compiler test suites.

On the other hand, I'm not sure which C++ compilers you were trying. It
works fine for me on VC6, VC7, g++/cygwin, g++/debian.

Piers.

-----Original Message-----
From: Joe Tennies [mailto:rotund@fatnsoft.com] 
Sent: Thursday, February 07, 2002 7:37 PM
To: mono-list@ximian.com
Subject: [Mono-list] [Fwd: Sample Test]


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.
> 



_______________________________________________
Mono-list maillist  -  Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list