function alias for functions of multiple variables

Can function aliases be made for functions with more than one argument?

There's this function call ImGui::Begin("text") that I'd like to turn into something like StartWindow("text").

So far, I've done:
1
2
const auto StartWindow = ImGui::Begin;
StartWindow("text")


But since begin's original definition contains 3 parameters total (2 of which has default values), VS2019 editor will complain "too few arguments to function call" when the code above is run.

Is this b/c StartWindow never had a declared function prototype or something? How could I achieve the result of being able to just call StartWindow("text")?

(I've just started to read intro C++ tutorials, but I thought this nagging question would best be put out first, if at all possible xD)
Is this b/c StartWindow never had a declared function prototype?

I think that's right.
But you can do it like this:

1
2
3
void StartWindow(const char *s) {  // or const std::string&
    ImGui::Begin(s);
}

Yeah that works, thanks :)
As an alternative, if you plan to narrow your new identifier scope (“StartWindow”), you can take advantage of the lambda syntax:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <iomanip>


struct ImGui {
    static void begin(const char* const cstr, int second = 0, bool third = false);
};


void ImGui::begin(const char* const cstr, int second, bool third)
{
    std::cout << cstr << ' ' << second << ' ' << std::boolalpha << third << '\n';
}


int main ()
{
    const auto startWindow1 = [](const char* const cstr) { ImGui::begin(cstr); };
    const auto startWindow2 = []() { ImGui::begin("text"); };
    startWindow1("Dummy text1 -->");
    startWindow2();
}

Topic archived. No new replies allowed.