This is not really a problem I have but more of me trying to understand classes better.
I don't know what this question or topic should be called. I could not find the answer to it or if it was posted before (because I don't know what it would be called). All I know is it has something to do with the String Class Arguments and how they are passed.
The only way I know how to pass an argument to a function or class is like this:
What is with the curly Braces now!?
How would you get that to work??
What does it pass through how do I begin to understand it?
If this question has been posted before or asked somewhere else before, please point me to it and I will gladly take this question down. I don't wish to post the same question it is was asked before already, I just don't know what it would be called to see if it was posted before.
Any help will be much appreciated,
Thank You very much.
I THINK that is another syntax to invoke the constructor (from WString.h):
String(const char *cstr = "");
C++ has several initialization syntaxes: (), =, {}. The differences between them seem rather esoteric to me. But, I'm sure there's a reason for them that perhaps someone may be able to explain.
For simple initializations, I've found that several forms will work. The compiler seems to get more picky as the initializations get more complex. I usually end up playing with different forms until the compiler is happy. Like I said, there's probably some subtle difference.
Side note
When you want to refer to a line number (or group of lines) from GitHub, just click on the line(s) number and a pop up menu will let you copy a direct link there.
In your example ➜ this will go to line 231
Or pasting the URL here alone at the start of a new line will show a few lines of the GitHub file around the selected line
The structure @issac25e is asking about includes the "String" class name at the beginning. So, it must be an instantiation of a String object. It's given a value at the same time. So, that makes it an initialization.
Instantiation of an object requires invoking the class's constructor. These are the available String constructors:
"String StringInstance" creates an instance of the String class. "StringInstance = "Some String Text" invokes the = over-ride to initialize the instance. Functionally, it is precisely equivalent to:
That page describes initialization of variables. We are not talking about variables here, but objects, which may contain numerous variables. This bout it - How could the compiler possibly know WHICH of those object member variables to intialize, OTHER than by using the defined = overload operator? Does it simply guess?