views:

81

answers:

2

Here is what I'm trying:

typedef cli::array<int> intarray;

int main(){
    intarray ^ints = gcnew intarray { 0, 1, 2, 3 };
    intarray::Reverse(ints);    // C2825, C2039, C3149

    return 0;
}

Compilation resulted in the following errors:

.\ints.cpp(46) : error C2825: 'intarray': must be a class or namespace when followed by '::'
.\ints.cpp(46) : error C2039: 'Reverse' : is not a member of '`global namespace''
.\ints.cpp(46) : error C3149: 'cli::array<Type>' : cannot use this type here without a top-level '^'
        with
        [
            Type=int
        ]

Am I doing something wrong here?

A: 

You're supposed to use . to call member functions. :: is only used for compile-time resolutions.

Edit: Whoops, I totally misread your code. You should use ints.Reverse(), rather than IntArray::Reverse(ints). Furthermore, it's totally possible that the rules for .NET types in C++/CLI are the same for .NET types in C#- that is, that dot should always be used.

DeadMG
cli::array<int>::Reverse(ints) works without a problem.
Vulcan Eager
A: 

That is an interesting question. Both the following notations do work

   ints->Reverse(ints);
   array<int>::Reverse(ints);

as you'd expect. Since typedef introduces a synonym, I'd expect it to work for you, but it obviously doesn't in VC++ 2008 Express.

Reilly