I'm declaring some strings that are empty, so it won't throw errors later on.
I've read that this was the proper way:
string Camnr = Klantnr = Ordernr = Bonnr = Volgnr = Omschrijving = Startdatum = Bonprioriteit = Matsoort = Dikte = Draaibaarheid = Draaiomschrijving = Orderleverdatum = Regeltaakkode = Gebruiksvoorkeur = Regelcamprog = Regeltijd = Orderrelease = "";
But that doesn't work. I get this error: Klantnr does not exist in the current context
.
What did I do wrong?
You can assign the same value to multiple variables by using = consecutively. This is useful, for example, when initializing multiple variables to the same value. It is also possible to assign another value into one after assigning the same value.
Example - Declaring multiple variables in a statementIf your variables are the same type, you can define multiple variables in one declaration statement. For example: int age, reach; In this example, two variables called age and reach would be defined as integers.
Using + operator The most common approach to concatenate multiple strings in C++ is to use the + operator, which is overloaded for string objects.
You can do it like:
string Camnr, Klantnr, Ordernr, Bonnr, Volgnr;// and so on. Camnr = Klantnr = Ordernr = Bonnr = Volgnr = string.Empty;
First you have to define the variables and then you can use them.
You can to do it this way:
string Camnr = "", Klantnr = "", ... // or String.Empty
Or you could declare them all first and then in the next line use your way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With