All Questions
Tagged with pass-by-reference oop
83 questions
2
votes
1
answer
59
views
C++: "No match for 'operator<<' (operand types are 'std::ostream' and 'Complex')"
I'm trying to compare and print two Complex objects using a custom Max function in C++. The Complex class has overloaded operator>> and operator<<, and I have also defined a bool operator&...
0
votes
1
answer
102
views
typescript transpiling error with find array method
I have this code in Typescript
/**
* Team information
*/
export class Team {
constructor( public name: string ) {}
}
/**
* Half side of each match, with team and score of the team
*/
...
1
vote
1
answer
21
views
In javascript, how do I make a class take an object's properties by reference?
I don't want to use the extends keyword because I am making a browser extension and I only have access to the instance, not class definition. so I am wondering if it is possible to assign the props of ...
0
votes
1
answer
335
views
How to get the name of the current environment THIS within a function
It looks like you can have one function pass data back transparently to a parent function with the assign operation.
Example (Setup)
calling = function()
{
a = 25;
cat("\n ...CALLING....
0
votes
2
answers
64
views
Implications of pass-by-value vs pass-by-reference in C# [duplicate]
I was following along a tutorial online about C#. The tutorial talks about passing-by-reference vs passing-by-value. What I am confused about specifically is that since in C#, there is a distinction ...
0
votes
0
answers
77
views
How to respect encapsulation principles in c++ without making the code unefficient?
i am a noobie in c++ programming and i'm developing a project in c++.
I am new to the all the OOP principles like encapsulation and inheritance, and due to this i have a doubt on how to properly ...
2
votes
3
answers
2k
views
In C#, when a variable passes through a function/method, will the original variable change?
I am confused by how a function can change a variable passed through it. For example, if I created a variable t = 1, and pass a function by adding 2 to it, inside the function t is 3, but in Main ...
0
votes
1
answer
57
views
Modeling circular dependencies while maintaining data integrity
I'm designing a music information system. I have a couple of entities that are connected to each other.
Below is part of the domain code.
class Album {
private Set<Track> tracks;
...
0
votes
1
answer
234
views
Trying to pass an array of pointers to objects, to a function of another class in C++ (not allowed to use vectors)
I have a class named Student. I create many student objects in my main (each object representing one student.)What i'm really trying to do is pass each one of these students to function enter of ...
3
votes
2
answers
359
views
Swap value of two attributes of two objects
I'm learning C++ (coming from Python) and I'm trying to understand how objects interact with each other. I wanted to create a class 'Point', that has two attributes (x and y coordinate) and give it a ...
0
votes
3
answers
76
views
Why does the method change passed array's value
I am making changes in a local variable and returning it. I think it should print 12 at line no 9.
public class HackerEarth {
int a[]= {3,4,5};
int b[]=foo(a);
void display() {
...
0
votes
0
answers
30
views
Why the value of my variable has changed from the function without explicitly passed by reference in OOP? [duplicate]
I know that in procedural PHP if you want to change the value of a variable from a function you need to pass it by reference using '&'. The default mode for passing variables into a function is ...
0
votes
1
answer
32
views
Passing Array as Argument to a Method
When we pass an array as argument to a method, the address of the first element is passed. Then, how the called method understand the number of elements in the received array?
1
vote
0
answers
73
views
Variable value getting changed after a function call in python
I am observing a weird behavior in variable values between python functions and I couldn't understand the proper reason behind it. I have two functions like below
def a():
seg_map = np.zeros([...
2
votes
2
answers
54
views
how slicing of derived classes occurs?
I'm having trouble understanding how slicing occurs? for example, in this piece of code:
class A {
public:
virtual h() {
cout << "type A" << endl;
}
};
class B : public A {
...