0

I create a constructor as follow

    Form1(array<System::String ^> ^args)    //HW5
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
        if (args->Length==0){
        CregArray = gcnew array<CRegistration^>(100);
        record_number = 0;
        }
        else {

        }
    }

After that I use a line of code to create the constructor. Basically, I want to use the case of length==0, but the compiler said there is an error. I don't understand what the compiler means.

Application::Run(gcnew Form1(""));

The error is "Error 1 error C2664: 'Project3::Form1::Form1(cli::array ^)' : cannot convert parameter 1 from 'const char [1]' to 'cli::array ^'

1 Answer 1

2

You are passing in a string where an array of strings is expected. Also, String::Empty is better practice than using a literal empty string.

Try this:

array<System::String^>^ args = gcnew array<System::String^>(1);
args[0] = String::Empty;
Application::Run(gcnew Form1(args));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.