Related
Izrin Recently, I stumbled across a comparison between Rust and C, they use the following code: bool f(int* a, const int* b) {
*a = 2;
int ret = *b;
*a = 3;
return ret != 0;
}
In Rust (same code, but with Rust syntax) it would generate the following a
Izrin Recently, I stumbled across a comparison between Rust and C, they use the following code: bool f(int* a, const int* b) {
*a = 2;
int ret = *b;
*a = 3;
return ret != 0;
}
In Rust (same code, but with Rust syntax) it would generate the following a
Izrin Recently, I stumbled across a comparison between Rust and C, they use the following code: bool f(int* a, const int* b) {
*a = 2;
int ret = *b;
*a = 3;
return ret != 0;
}
In Rust (same code, but with Rust syntax) it would generate the following a
Izrin Recently, I stumbled across a comparison between Rust and C, they use the following code: bool f(int* a, const int* b) {
*a = 2;
int ret = *b;
*a = 3;
return ret != 0;
}
In Rust (same code, but with Rust syntax) it would generate the following a
username Are int const *aand const int *amean "a is an integer pointer to a constant value" and "a is a pointer to a constant address" respectively, or vice versa? This was asked me in an interview. After reading a lot about the same thing, I'm still very conf
enough A const reference ensures that you cannot change the object you are referencing. E.g: int i = 1;
const int& ref = i;
ref = 42; // error, because of a const reference
However, if you use a reference to a pointer or unique_ptr, you can. example: class Ti
enough A const reference ensures that you cannot change the object you are referencing. E.g: int i = 1;
const int& ref = i;
ref = 42; // error, because of a const reference
However, if you use a reference to a pointer or unique_ptr, you can. example: class Ti
enough A const reference ensures that you cannot change the object you are referencing. E.g: int i = 1;
const int& ref = i;
ref = 42; // error, because of a const reference
However, if you use a reference to a pointer or unique_ptr, you can. example: class Ti
enough A const reference ensures that you cannot change the object you are referencing. E.g: int i = 1;
const int& ref = i;
ref = 42; // error, because of a const reference
However, if you use a reference to a pointer or unique_ptr, you can. example: class Ti
enough A const reference ensures that you cannot change the object you are referencing. E.g: int i = 1;
const int& ref = i;
ref = 42; // error, because of a const reference
However, if you use a reference to a pointer or unique_ptr, you can. example: class Ti
enough A const reference ensures that you cannot change the object you are referencing. E.g: int i = 1;
const int& ref = i;
ref = 42; // error, because of a const reference
However, if you use a reference to a pointer or unique_ptr, you can. example: class Ti
Ning Hao So I tried to change my game, but I found a problem that I can't change: I have the following code: std::string fileContents = "";
const char* contentsPtr = fileContents.c_str();
I tried doing: const std::unique_ptr<char> contentsPtr = fileCont
Barry In short, is it better to pass pointers by value or const reference? I wrote a simple function to explore: void foo(int* v) { std::cout << *v << endl; }
and void foo(int* const& v) { std::cout << *v << endl; }
I tried looking at the generated assembly,
username For example, I have two classes Playerand Gamea field Gamewith playera pointer to Player. As the Parse documentation states, it save's recursive, so I'm assuming I can save a playerby just saving a game, like: let player = PFObject(className: "Player"
username For example, I have two classes Playerand Gamea field Gamewith playera pointer to Player. As the Parse documentation states, it save's recursive, so I'm assuming I can save a playerby just saving a game, like: let player = PFObject(className: "Player"
Willie Freddy This week, we were tasked with creating a program that: Program to display the address and value of an array User enters the appropriate address to change The user enters a new value for the address I was able to figure out how the pointer works,
Sorter So I have a similar function (simplified example): void somefunction(structuraltype *something) {
something->variable = 6;
}
As you can see I can easily access the value using -> But I realize that I have to use a pointer to a pointer, not a sing
Richard Topch Consider I have a C function: MyFunction(const char *value, bool trigger)
Internally, depending on the value of the triggervariable , I would like to either use the one valueprovided to the function, or simply overwrite it with some other string
Wengers I have the following code: #include <iostream>
int main(){
int v1 = 20;
int *p1 = &v1;
int **p2 = &p1;
return 0;
}
What I'm trying to do here is point one pointer to another and it works fine in this case. I make p1 point to a cons
swing machine I pass in a double pointer to a function, and the function allocates space on the heap and redirects the double pointer to that memory location. Then on the main side we should be able to access the memory location and its contents my code: void
Ernestas I came across a similar snippet of code today, and it struck me as odd. I did a small experiment myself as shown below. Why does the first function stuffwith a shared pointer allow to modify the value but the second does not? #include <memory>
void s
Ernestas I came across a similar snippet of code today, and it struck me as odd. I did a small experiment myself as shown below. Why does the first function stuffwith a shared pointer allow to modify the value but the second does not? #include <memory>
void s
Ernestas I came across a similar snippet of code today, and it struck me as odd. I did a small experiment myself as shown below. Why does the first function stuffwith a shared pointer allow to modify the value but the second does not? #include <memory>
void s
Ernestas I came across a similar snippet of code today, and it struck me as odd. I did a small experiment myself as shown below. Why does the first function stuffwith a shared pointer allow to modify the value but the second does not? #include <memory>
void s
Ernestas I came across a similar snippet of code today, and it struck me as odd. I did a small experiment myself as shown below. Why does the first function stuffwith a shared pointer allow to modify the value but the second does not? #include <memory>
void s
Philip I have a strange problem. I'm thinking of the following example, where I'm passing a pointer by reference, so if I change the pointer address of the parameter, the initial pointer should also change the address. This does happen. However, the value of a
Philip I have a strange problem. I'm thinking of the following example, where I'm passing a pointer by reference, so if I change the pointer address of the parameter, the initial pointer should also change the address. This does happen. However, the value of a
Guerlando OC I've been trying to write a small matrix framework in C. The problem is that the components accessing the matrix are modifying it in some way. You'll see that the elements of the matrix achange weirdly after being passed to matrix_scalar_multiply.
learning_cpp I'm trying to build an Oct tree structure, but the value of the pointer seems to have changed during runtime. insert() simulates insertion by randomly adding children to the parent node, and show() is used to display all elements on the path. Each