Skip to main content
0 votes
1 answer
68 views

How to assign a new object to a reference?

Why can't I do it like this in Go? func do(m1 map[int]string) { var m map[int]string = make(map[int]string) *m1 = &m; } I have m1 map, which means I can now it's reference? How to assign ...
Pasha's user avatar
  • 1,988
-1 votes
1 answer
109 views

Function return value and assignment in C++ [duplicate]

In C++ or for any other language, I wish to know that if a function returns a local variable in it's scope to a caller and assigns it to some other variable, how do the semantics work? An example in C+...
uvnarayan's user avatar
0 votes
2 answers
98 views

Dereferecing a private variable unordered_map whose key is a custom struct in a class leads to a seg fault

I'm working on a mini project where I'm implementing the Matrix Chain Multiplication.My implementation is building a tree where the nodes are defined as struct Node { char* seq; Node* left; ...
samueltru99's user avatar
0 votes
0 answers
109 views

Do pointers also point to C style strings? [duplicate]

From my knowledge of pointers if, am right, pointers are holder of memory address, so how does pass by const char pointer which took in an RVALUE even work. Here's the code. #include <iostream> ...
Ammishaddai Boakye's user avatar
1 vote
1 answer
53 views

Why am I receiving a heap corruption error in IntegerSet class?

I have an assignment in which I have to create a class called IntegerSet. The point is that it creates sets of integers. If an integer is present in the set, then that number has a 1 in its place in ...
Joe Forsyth's user avatar
0 votes
2 answers
241 views

Struct variable passed by value vs. passed by pointer to a function

Let's say I have the following structure: typedef struct s_tuple{ double x; double y; double z; double w; } t_tuple; Let's say I have the two following functions: t_tuple ...
BobDeTunis's user avatar
0 votes
4 answers
222 views

C dynamic allocation of an array under struct inside a function

I have a struct that will contain some dynamic-allocated array. I have written the following code, and it works but I do not understand why it does work. #include <stdio.h> #include <stdlib.h&...
Sangjun Lee's user avatar
0 votes
0 answers
73 views

What is value, reference vs pointer and what these three example used to pass? [duplicate]

I am recently studying golang and realize that everything passed to a go function get a new copy of same type with different address? Is it something what we call pass by value? https://go.dev/play/p/...
Stan's user avatar
  • 882
0 votes
1 answer
341 views

When a function is given as an argument to a function, is it pass-by-value or pass-by-pointer [closed]

Take this example - func funcB() { fmt.Println("Hi") }) funcA(funcB) Is funcA receiving a pointer to funcB? Or is it receiving a full-blown immutable function? So, if I execute this code - ...
snath03's user avatar
  • 130
0 votes
0 answers
63 views

Array problems in C: Do I need to pass a single array cell back to my global array by reference in C?

I am manipulating the row and column within a user-defined function called dropmove, and I am currently stuck on the method of passing and returning the array cell/value into my global array. I am ...
Ryan Paye's user avatar
0 votes
2 answers
215 views

removing x from a string using pass by pointer with recursion

I wrote this code to remove all occurrences of x from the string using recursion #include <bits/stdc++.h> using namespace std; void removex(string str) { if (str.length()==0) { ...
parasguglani's user avatar
1 vote
1 answer
58 views

c++ pointers with overloaded functions and user input

I'm getting multiple errors.. I've tried this with different variables and different data types. I clearly don't understand how to use pointers properly. I am not looking for someone to give me the ...
Tamara's user avatar
  • 27
0 votes
3 answers
2k views

Pass by reference vs pointer

I am having a hard time wrapping around knowing when to use pointers vs references. My question is: in Java/C# you can pass an object as an argument to a function and then assign this argument to an ...
Enk73a's user avatar
  • 49
0 votes
0 answers
35 views

Why is the execution order different in addition and subtraction? [duplicate]

I have a function that takes one argument by address and changes the value of the argument. But when I call the function, the order of execution is different in cases of addition and subtraction: #...
Hadi GhahremanNezhad's user avatar
0 votes
0 answers
49 views

Pass a global variable to a method as an argument

Global Variable: int REGISTRATION_SIZE = 10; I want to pass a global variable(REGISTRATION_SIZE) to wait_for_avaliable method as method argument like wait_for_avaliable(int size). How can I achieve ...
AssSoonAsPossiblee's user avatar

15 30 50 per page
1
2 3 4 5
7