Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ECE2574_Function_Calling_Example
// clang 3.8.0 // Example from Lecture 5 in class on calling functions // by reference and vale #include <iostream> using namespace std; void myFuncByValue(int n) { n++; } void myFuncByReferenceCStyle(int *n) { (*n)++; } void myFuncByReferenceCppStyle(int &n) { n++; } int main() { int i = 3; cout << "Test Program for calling functions" << endl; // Calling by value cout << "Value of i prior to calling myFuncByValue is: " << i << endl; myFuncByValue(i); cout << "Value of i after to calling myFuncByValue is: " << i << endl; // Calling by reference C-style cout << "Value of i prior to calling myFuncByReferenceCStyle is: " << i << endl; myFuncByReferenceCStyle(&i); cout << "Value of i after to calling myFuncByReferenceCStyle is: " << i << endl; // Calling by reference C++-style cout << "Value of i prior to calling myFuncByReferenceCppStyle is: " << i << endl; myFuncByReferenceCppStyle(i); cout << "Value of i after to calling myFuncByReferenceCppStyle is: " << i << endl; return 0; }
run
|
edit
|
history
|
help
0
non-deduced context
Unlike C (even C99/C11), C++ allows initializers in if-conditions, so this compiles.
C++ Program to Print Binary
Heap: insert and deleteMin() Implementations
Atomic trivial default constructor
IsContainer
C++17 function traits not works
Struct memory ordering
How to test call member?
Делим на Ноль