JohnRob:
In this particular case it seems to me both initiate the I2C port of the 328p.
As I already explained, they don't.
JohnRob:
why would a programmer choose to use the "begin(TwoWire.." approach over the Wire.begin approach?
There's no choice. They are not equivalent. In a library, you need the function prototype and then if you want to use the function you need to call it. That's how C++ works
Not believing what some random person on the Internet tells you is reasonable, though I'm not sure what the point is of asking on a forum is if you're just going to disregard the information provided.
Not believing what a well established and trusted C++ website tells you seems quite excessive.
Inventing your own meaning for some code and stubbornly sticking to that belief with absolutely no evidence to back it and good evidence to the contrary is insanity.
Luckily we can use the scientific method to determine the truth.
Question: what does a function prototype do?
Your hypothesis: a function prototype calls the function.
Prediction: If I run a sketch that only contains a function prototype and a function definition, it will execute the code in the function definition.
Experiment:
Let's simplify the code as much as possible to make it very easy to understand. There is no need for a class or to deal with the Wire library. We just need a function that does something that's easy to observe and unambiguous. Although the Arduino IDE will automatically generate function prototypes for you, you are also welcome to write your own, as I have done here.
Upload the following sketch:
// blink function prototype
void blink();
void setup() {}
void loop() {}
// blink function definition
void blink() {
pinMode(LED_BUILTIN, OUTPUT);
while (true) {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
}
Observe the built-in LED on the Arduino board to see whether it blinks.
Results: The LED does not blink.
Analysis: A function prototype does not execute the function.
My hypothesis: You must call the function to execute the code in the function.
Prediction: If I run a sketch that only calls a function, it will execute the code in the function definition.
Experiment:
Upload the following sketch:
// blink function prototype
void blink();
void setup() {
// blink() call
blink();
}
void loop() {}
// blink function definition
void blink() {
pinMode(LED_BUILTIN, OUTPUT);
while (true) {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
}
Observe the built-in LED on the Arduino board to see whether it blinks.
Results: The LED blinks.
Analysis: A function call executes the function.
Case closed!
The great thing about computer science is that it's often so incredibly easy to run experiments. When you want to learn what some code does, just write some simplified sketches to test the code, upload them to your board, and check whether they act as you predicted.