1,366 questions
-2
votes
2
answers
124
views
Blackhole assignment in R [duplicate]
Suppose I have the following:
df1 <- data.frame(id=c(1,2,3))
df2 <- data.frame(id=c(2,3,4))
I want to print: (1) The number of IDs in df1 but not in df2, (2) the number of IDs in df2 but not in ...
-1
votes
1
answer
49
views
QSharedDataPointer for private data: how to write a good copy operator where a copy may be deleted
I had to implement a copy operator for a class which contains a QSharedDataPointer to the private data. Which is working, but only as long as I do not delete one of the copies. Other than expected it ...
0
votes
3
answers
111
views
Expressions in C. Are assignments expressions despite semicolons?
I am currently learning C and in one slide the professor states that Semicolons added to an expression makes it a statement. While on the other hand it mentioned that all assignments are expressions. ...
6
votes
1
answer
162
views
Overload resolution for copy assignment operator
In addition to an implicitly-defined copy assignment operator, if a class also defines an operator= without an lvalue-reference object parameter, which of the operators must be selected?
Please ...
2
votes
4
answers
131
views
wierd syntax with parentheses in C [duplicate]
I was given the code:
#include <stdio.h>
int main(void) {
int a = 0, b = 0, c = 0;
c = (a -= a - 5), (a = b, b + 3);
printf("a = %d, b = %d, c = %d", a, b, c); // a = 0, b =...
3
votes
1
answer
53
views
hard-to-understand error in an augmented assignment statement in Kotlin
This is a contrived example for the sake of my understanding Kotlin language.
The class Box<T> below models a box that contains boxes of the same type T.
The question is why arr += x causes ...
0
votes
0
answers
41
views
Python str = str + value is slow [duplicate]
I am writing 2 Mbyte file line by line and using string variable to populate the data line by line first
When i did in loops str = str + new_data it took couple seconds to process the script.
Once i ...
-1
votes
1
answer
69
views
dollar sign $ as an assignment operator for a value of string in vs code ( js ) does not work or highlighted [closed]
function sayHello (userName) {
console.log ('Hello ${userName}') ;
}
sayHello ('Mena') ;
function sayHello (userName) {
console.log ('Hello ${userName}') ;
}
sayHello ('mena') ;
// i ...
1
vote
1
answer
151
views
why does final_dictionary = starting_dictionary["c"] = 7 not assign starting_list with added key-value pair to final_dictionary
**How are these two different.
**
(1)
starting_dictionary = {
"a": 9,
"b": 8,
}
final_dictionary = {
"a": 9,
"b": 8,
"c": 7,
}
...
0
votes
0
answers
55
views
Inherit custom operator= from template base class [duplicate]
I have a template base class that implements void operator=(T value). Then I have a derived template class which should just inherit that operator, but this doesn't work. (See compile error in the ...
0
votes
1
answer
74
views
In-place swap using tuple assigment statement
In-place swap is a technique, which is used to swap a content of two distinct variables without any temporary storage variable.
GoLang Spec mentions: A tuple assignment assigns the individual elements ...
0
votes
0
answers
110
views
"void" Return type for overloaded operator [duplicate]
I am currently studying "Object-oriented design choices" by Dingle (2021), a required textbook for my Object-Oriented Design Class. While going through the chapter on "Move Semantics,&...
0
votes
0
answers
91
views
std::optional<T> assignment operators
My reference is to options (4), (5) and (6) of std::optional::operator=
Given the premise that
The class template std::optional manages an optional contained value, i.e. a value that may or may not be ...
-2
votes
3
answers
104
views
Assignment operator += usage with earlier declared vs declared variable?
I am new to C and got a little confused. I have code where I am using += operator with a variable when declared but it is giving me an error for this operator, but working fine when used inversely i.e....
6
votes
3
answers
308
views
Copy semantics and vectors
I am dealing with objects that allocate memory for internal use. Currently, they are not copyable.
E.g.
class MyClass
{
public:
MyClass() { Store = new int; }
~MyClass() { delete Store; }
...
4
votes
2
answers
111
views
Why can't the compiler find the assignment operator?
template <typename T>
class MyPointer
{public:
template <typename U>
void operator=(MyPointer<U>&& other)
{
}
char* get() const { return pointer; }
...
2
votes
1
answer
91
views
JavaScript Operator Precedence, Assignment, and Increment?
In JavaScript (JS), ++ has higher precedence than += or =. In trying to better understand operator execution order in JS, I'm hoping to see why the following code snippet results in 30 being printed?
...
2
votes
1
answer
155
views
How are C declarations actually parsed, based on this interesting discrepancy?
It's fairly common to see a declaration and assignment combined like this:
int beans = a * 2;
or separate, like this
int beans;
beans = a * 2;
My current understanding is that beans can be assigned ...
0
votes
1
answer
68
views
Assignment operator overloading for templated matrix class
I am implementing assignment operator function for a template matrix class.
It should take care of different datatype matrix assignments. eg Integer matrix is assigned to a double matrix.
for that i ...
5
votes
1
answer
173
views
Assignment operator in C
volatile int lhs = 1;
int rhs = 2;
int x = 3;
x = lhs = rhs;
Does an assigment operator return the (typeof lhs)rhs ? or Does it return new, just read value of lhs ?
It is important to me since lhs ...
0
votes
1
answer
130
views
How do I assign values from a dictionary to a dataframe column in equal numbers?
I have a list of sales reps for one of 5 territories. I need to assign them to a list of leads in equal numbers.
Here's an example of the dictionary:
d = {'Large': 'Jackson', 'Large': 'Stevens', '...
4
votes
1
answer
1k
views
How can I define a custom assign operator overload in Kotlin?
I have a Kotlin class that wraps a mutable value.
class StringWrapper(
var value: String = ""
) {
override fun toString(): String = value
}
I use this wrapper as properties in a custom ...
0
votes
2
answers
127
views
Usage of '+=' in c
I don't understand why, on this code, 'b+=' return 6 instead of 5. The operation on right-end of operator '+=', should be 0.
i/2 = 4
a-4= 0
So Operator '+=' should just add: 0.
#include<stdio.h&...
0
votes
0
answers
157
views
Assignment Operator in JS: Unary or Binary?
we use an assignment operator = in order to assign a value to a variable, so the value assigned is an operand but the variable itself counts as another one?? if not is only a unary operator, that ...
-1
votes
1
answer
91
views
Inheriting operator= and constructor but also add an extra wrapper assignment
I have the following struct:
struct Feedback : public TaggedUnion<Feedback1Idx, String>
{
using TaggedUnion<Feedback1Idx, String>::TaggedUnion;
using TaggedUnion<Feedback1Idx, ...