[Solved] How to declare multiple variables in Turbo C++


Even Turbo C++ implemented this in a correct way decades ago.

Function parameters need to be declared giving their types explicitly:

char create_username(char forename, char surname)
                                 // ^^^^ This is needed!

in contrast to declaring a bunch of local variables, where the multiple definition syntax can be used:

void foo() {
    char forename, surname;
}

Also note that char only stores a single character, and you’re not able to store a forename/surname.

The type rather should be std::string.


As you’re clarifying your requirements in this comment

I am trying to make a username by joining using the first letter of the forename and the full surname, …

your function should rather look like:

std::string create_username(const std::string& forename, const std::string& surname) {      
     return std::string(forename[0],1) + surname;
}

1

solved How to declare multiple variables in Turbo C++