function f(by_val x) {
x++
}
function g(by_ref x) {
x++
}
a = 1
f(a)
print(a) –> 1
g(a)
print(a) –> 2
#include <iostream>
#include <stdlib>
using namespace std;
void f(int x) {
x++;
}
void g(int& x) {
x++;
}
int main() {
int a = 1;
cout << a << endl; // will print 1
f(a);
cout << a << endl; // will print 1
g(a);
cout << a << endl; // will print 2
}
void pointless(CHAR_DATA& ch) {…
// in pointless function
void pointless(CHAR_DATA& ch) {
ch.levelup(); …
void pointless(CHAR_DATA& ch) {…
// in pointless function
void pointless(CHAR_DATA& ch) {
ch.levelup(); …
I know that using the & operator in C that it is the memory address of the variable:
In some of the documentation I've read on c++ it shows examples like:
Does the '&' operator point to the memory address of the list?