Skip to main content
Filter by
Sorted by
Tagged with
-4 votes
2 answers
149 views

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 ...
robertspierre's user avatar
5 votes
2 answers
161 views

I am porting a large codebase from Linux/g++ to MacOS/Clang. I hit this compiler error in multiple places in Clang (where g++ builds successfully and does the right thing at run time): error: ...
barnabas's user avatar
  • 157
-1 votes
1 answer
49 views

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 ...
Jodeli's user avatar
  • 11
3 votes
1 answer
138 views

Snip: #include <optional> template <typename> class MyOpt; template <typename T> MyOpt(T) -> MyOpt<T>; template <typename T> class MyOpt : private std::optional<...
Juergen's user avatar
  • 3,769
0 votes
3 answers
112 views

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. ...
Qingyang Gu's user avatar
1 vote
1 answer
97 views

Many, many, many posts about inheriting operator=, with the usual answer being "it's overshadowed by the implicitly defined one, use using Base::operator= if you know what you're doing". ...
Michaël's user avatar
  • 579
6 votes
1 answer
162 views

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 ...
Fedor's user avatar
  • 24.7k
1 vote
1 answer
76 views

I cannot find the definition of the = operator on its official document, neither can I find it in the source code of QChar. But I can use = without problem. QChar c = QChar('c'); QChar d = c; c = d; ...
William's user avatar
  • 978
2 votes
4 answers
131 views

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 =...
xiushama's user avatar
0 votes
0 answers
42 views

In this snippet of C90: extern float foo(); int bar(int a) { int b = (foo(), a); // <- this line return b; } Will foo() be evaluated? What will happen to its return value?
totikom's user avatar
  • 306
3 votes
1 answer
54 views

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 ...
Royalblue's user avatar
  • 701
0 votes
1 answer
44 views

I need some help eith the following code in Python, is an implementation of an ALNS heuristic for vrp that I'm trying to create. def run_heuristic(num_customers, num_vehicles, num_iterations, ...
Lkmuraz's user avatar
  • 141
0 votes
0 answers
42 views

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 ...
Roman Toasov's user avatar
1 vote
1 answer
129 views

I'm trying to use a struct to pack multiple smaller integers into a uint32_t. struct PackedData { PackedData & operator=(uint32_t x) { a = (x >> 24) & 0xFF; b = (x &...
Zak's user avatar
  • 12.7k
-1 votes
1 answer
69 views

function sayHello (userName) { console.log ('Hello ${userName}') ; } sayHello ('Mena') ; function sayHello (userName) { console.log ('Hello ${userName}') ; } sayHello ('mena') ; // i ...
Mena Makrem's user avatar
0 votes
1 answer
134 views

I have 2 classes. Pointer to an array of fixed width and Pointer to a Pointer for implementing 2d array of floats. I wanted to understand, if and how can I use memcpy for my Copy constructor and ...
Sourabh's user avatar
  • 787
1 vote
1 answer
151 views

**How are these two different. ** (1) starting_dictionary = { "a": 9, "b": 8, } final_dictionary = { "a": 9, "b": 8, "c": 7, } ...
Vyagh's user avatar
  • 11
-1 votes
1 answer
144 views

I have written the following simple C++ program to output the powers of a number input by the user to indices 2, 3, and 4: int a = 0; cin >> a; int a2 = a * a; cout << "\n" &...
Ali Kamel Ali's user avatar
0 votes
0 answers
55 views

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 ...
Thomas Klier's user avatar
2 votes
1 answer
95 views

I don't understand why a = b doesn't print out value from operator= 5 like operator+ (which seems to allows derivatives). Why does it do this instead of allowing derivatives and how can I make it ...
haiter's user avatar
  • 23
0 votes
1 answer
80 views

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 ...
user1787812's user avatar
25 votes
3 answers
3k views

I have written the code: int x = 18; x *= 0.90; System.out.println(x); This code printed 16 However, when I wrote int x = 18; x = x * 0.90; System.out.println(x); it gave me the following error: ...
pprav's user avatar
  • 269
0 votes
0 answers
113 views

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,&...
i_hate_F_sharp's user avatar
3 votes
1 answer
104 views

I have been delving into the intricacies of C++ recently, and there's a specific behavior that has puzzled me: the rules and behaviors around temporaries, especially regarding taking their address and ...
sam's user avatar
  • 911
0 votes
0 answers
91 views

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 ...
Vinod's user avatar
  • 1,215
0 votes
1 answer
120 views

I'm trying to use the complex<> type to implement a Point class, for geometry problems. I would like to be able to assign the value of the real and imaginary parts of the variable individually, ...
For's user avatar
  • 144
-2 votes
3 answers
104 views

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....
user3737377's user avatar
4 votes
1 answer
144 views

In C++ there is the infamous problem of self-assignment: when implementing operator=(const T &other), one has to be careful of the this == &other case to not destroy this's data before copying ...
yeputons's user avatar
  • 9,308
6 votes
3 answers
308 views

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; } ...
user avatar
1 vote
1 answer
203 views

I have a class that can't be re-assigned. The actual motive is that it has an std::variant member variable, and the possible types are not re-assignable, due to having some reference member variables (...
BlueMoon93's user avatar
  • 2,960
4 votes
2 answers
112 views

template <typename T> class MyPointer {public: template <typename U> void operator=(MyPointer<U>&& other) { } char* get() const { return pointer; } ...
Zebrafish's user avatar
  • 16.3k
-2 votes
2 answers
123 views

I'm new at the site but I've been looking to know the difference of the applications of ":" and "=". I know that "=" is an assignation operator, like a= 12, so like b= ...
neil__r's user avatar
2 votes
1 answer
91 views

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? ...
mishar's user avatar
  • 455
0 votes
0 answers
74 views

The function below works with the return type Class, Class& and void. So, what's the difference between each? //deep copies one object into another Club& Club::operator= (Club& obj) { ...
happy's user avatar
  • 1
2 votes
1 answer
155 views

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 ...
Aaron Linnell's user avatar
-3 votes
1 answer
84 views

I am trying to buld the vector library . The code looks like this #include <iostream> #include <string> namespace std { template<typename T> class vector { private: ...
satej dhakane's user avatar
0 votes
1 answer
68 views

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 ...
Renu's user avatar
  • 29
2 votes
1 answer
235 views

When we didn't define any = operator, how does the compiler know to use constructors? Isn't the constructor only called when defining a variable? #include <string> class Person { public: ...
Jibel's user avatar
  • 235
5 votes
1 answer
176 views

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 ...
OODAX's user avatar
  • 159
1 vote
1 answer
124 views

I'm learning Java, and I have a question about the properties of the return value of the assignment operation. I know that Java returns the value of the variable after assignment in x = y, but when ...
Arxel's user avatar
  • 35
0 votes
1 answer
130 views

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', '...
reenum's user avatar
  • 1
13 votes
2 answers
1k views

I learned that we could provide conversion operators for our classes in C++. So I expected that for the following program, c=1; would've used the conversion operator int(). But to my surprise; that ...
Sam's user avatar
  • 166
4 votes
1 answer
1k views

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 ...
aSemy's user avatar
  • 7,547
-3 votes
1 answer
82 views

Every time I try this the console log prints 12 instead of 10: let number1 = 3; let number2 = 2; number1 += number2; number2 += number1; let result = number1 + number2; console.log(result);
XVNVSX's user avatar
  • 1
0 votes
2 answers
127 views

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&...
ivan pasquini's user avatar
1 vote
2 answers
102 views

Take a simple class wrapping an int, struct Foo { int x; } f; and a class that holds a Foo and that can be converted to it, struct Bar { Foo f; operator Foo&() { return f; ...
Enlico's user avatar
  • 30.3k
0 votes
0 answers
157 views

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 ...
Cristian Lopez's user avatar
3 votes
0 answers
713 views

"-" with the "option" key (refers ALT key) had been used as the assignment operator. Since RStudio became POSIT the combination of these buttons not just working in RStudio. But ...
Erkan AĞASLAN's user avatar
-1 votes
1 answer
91 views

I have the following struct: struct Feedback : public TaggedUnion<Feedback1Idx, String> { using TaggedUnion<Feedback1Idx, String>::TaggedUnion; using TaggedUnion<Feedback1Idx, ...
ZeroZ30o's user avatar
  • 396
1 vote
0 answers
52 views

Context: I'm mainly a Javascript/Python developer and I'm doing Java just for schoolwork. This is the code block that perplexes me. public static void display(int a, int b) { a = a+b-(b=a); System....
Aadivya's user avatar
  • 11

1
2 3 4 5
28