Incompatibility using managed array and std:array at same time

前端 未结 1 1812
-上瘾入骨i
-上瘾入骨i 2020-12-15 04:56

I have my C++/CLI code using arrays like this (for example):

array^ GetColNames() { 
    vector vec = impl->getColNames();
           


        
相关标签:
1条回答
  • 2020-12-15 05:25

    Clearly you have a using namespace std; in scope somewhere. Watch out for it being used in .h file if you cannot find it.

    You can resolve the ambiguity, the C++/CLI extension keywords like array are in the cli namespace. This compiles fine:

    #include "stdafx.h"
    #include <array>
    
    using namespace std;         // <=== Uh-oh
    using namespace System;
    
    int main(cli::array<System::String ^> ^args)
    {
        auto arr = gcnew cli::array<String^>(42);
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题