Search code examples
visual-studioc++-clipanel

How to send objects to a function properly?


So I have a class called "Screen" and function:

void closeAllTabs(Panel leftTab, Panel rightTab);

I am sending 2 objects of type panel there. Further down in my main class, I try to call the function like this:

Screen scr;
scr.closeAllTabs(leftMainTab, rightMainTab);

But when I try to call this function and send the panels there, I get an error.

C++ function cannot be called with the given argument list argument types are: (System::Windows::Forms::Panel ^, System::Windows::Forms::Panel ^) object type is: ProjectName::Screen


Solution

  • I should have add reference

            void closeAllTabs(Panel ^leftTab, Panel ^rightTab);
    

    Thank

    the error is reasonably clear? You need to change the parameters to match the type of the arguments by adding ^ to make them refs – Alan Birtles

    apologize for immediately writing here without examining the error :P