assignment-operator Questions
1
Solved
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 con...
Hermineherminia asked 3/8 at 20:27
2
I love the package but I was wondering how I could change one rule from the tidyverse style: I'd like to keep "=" instead of "<-" for assignment.
I've read that note: http://styler.r-lib.org/ar...
Stockholm asked 2/6, 2018 at 19:26
3
Solved
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...
Paymar asked 8/12, 2023 at 4:15
4
Solved
I am just starting C++. I am a bit confused about the return type of assignment and dereference operator. I am following the book C++ Primer. At various occasions, the author says that the return t...
Cromagnon asked 8/3, 2013 at 11:25
3
Solved
We have equivalent assignment operators for all Logical operators, Shift operators, Additive operators and all Multiplicative operators.
Why did the logical operators get left out?
Is there a good...
Windswept asked 14/6, 2011 at 15:23
3
Solved
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; }
privat...
Breakwater asked 1/8, 2023 at 7:40
12
Solved
Until today, I thought that for example:
i += j;
Was just a shortcut for:
i = i + j;
But if we try this:
int i = 5;
long j = 8;
Then i = i + j; will not compile but i += j; will compile fi...
Natant asked 3/1, 2012 at 10:10
1
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 lh...
Winter asked 11/5, 2023 at 19:23
2
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...
Erotic asked 24/4, 2023 at 13:35
5
Solved
This is a common pattern I use to index tokens as they come in: check if the token is in a map, and if not, add it to the map, assigning the map's size.
When doing this in C++, it unexpectedly inc...
Halhalafian asked 4/8, 2013 at 5:37
13
Is there a magic method that can overload the assignment operator, like __assign__(self, new_value)?
I'd like to forbid a re-bind for an instance:
class Protect():
def __assign__(self, value):
...
Kirtley asked 13/6, 2012 at 23:13
9
Solved
What are the differences between the assignment operators = and <- in R?
I know that operators are slightly different, as this example shows
x <- y <- 5
x = y = 5
x = y <- 5
x <- ...
Teetotum asked 16/11, 2009 at 12:14
4
Solved
A post on here a day back has me wondering how to assign values to multiple objects in the global environment from within a function. This is my attempt using lapply (assign may be safer than <&...
Radie asked 15/3, 2012 at 19:24
6
Solved
Can I assign a pointer to an integer variable? Like the following.
int *pointer;
int array1[25];
int addressOfArray;
pointer = &array1[0];
addressOfArray = pointer;
Is it possible to do l...
Inimitable asked 7/5, 2012 at 20:57
8
Solved
In C++, the concept of returning reference from the copy assignment operator is unclear to me. Why can't the copy assignment operator return a copy of the new object? In addition, if I have c...
Ole asked 23/6, 2010 at 21:45
1
Solved
For example, the assignment operators for std::slice_array:
void operator=(const valarray<T>&) const; //#1
void operator=(const T&) const; //#2
const slice_array& operator=(const ...
Benumb asked 7/10, 2022 at 8:39
4
int& foo() {
printf("Foo\n");
static int a;
return a;
}
int bar() {
printf("Bar\n");
return 1;
}
void main() {
foo() = bar();
}
I am not sure which one should be evaluated first.
I h...
Mond asked 28/11, 2011 at 11:33
12
So for binary operators on booleans, Java has &, |, ^, && and ||.
Let's summarize what they do briefly here:
JLS 15.22.2 Boolean Logical Operators &, ^, and |
JLS 15.23 Condition...
Extrovert asked 24/2, 2010 at 8:25
1
Solved
Suppose sizeof( int ) == sizeof( float ), and I have the following code snippet:
union U{
int i;
float f;
};
U u1, u2;
u1.i = 1; //i is the active member of u1
u2.f = 1.0f; //f is the active mem...
Majestic asked 31/8, 2022 at 11:39
1
Solved
After many years of using C++ I realized a quirk in the syntax when using custom classes.
Despite being the correct language behavior it allows to create very misleading interfaces.
Example here:
c...
Trull asked 20/5, 2022 at 6:54
3
Solved
I have extended std::string to fulfil my needs of having to write custom function build into string class called CustomString
I have defined constructors:
class CustomString : public std::strin...
Hammett asked 14/7, 2012 at 2:29
4
Solved
Is there any good reason for operator = not being a sequence point? Both in C and C++.
I have trouble thinking about an counter-example.
Deceive asked 6/12, 2010 at 1:30
4
Solved
I'm doing some revision of my C++, and I'm dealing with operator overloading at the minute, specifically the "="(assignment) operator. I was looking online and came across multiple topics discussin...
Medieval asked 30/1, 2012 at 23:6
3
Solved
So the nullish coalescing assignment operator ??= assigns the value to the variable only if the current stored value is nullish.
Maybe I'm missing the obvious but I can't think of a slick solution ...
Lelandleler asked 24/11, 2021 at 20:42
3
Solved
I have the following code:
#include <vector>
#include <iostream>
std::vector <int> a;
int append(){
a.emplace_back(0);
return 10;
}
int main(){
a = {0};
a[0] = append();
s...
Eavesdrop asked 29/10, 2021 at 0:1
1 Next >
© 2022 - 2024 — McMap. All rights reserved.