python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Getter returns a rvalue?
I know it's a bad attempt but why we cannot edit the private member via the getter?
class A
{
int a = 2;
public:
int GetA1() { return a; }
int& GetA2() { return a; }
int* GetA3() {...
ripfreeworld
Votes: 0
Answers: 3
what does func() = var_name; assignment do in c++?
I was studying about l-values and r-values but I am confused with this:
#include<iostream>
int& get_val(){
return 10;
}
int main(){
get_val() = 5;
int a = get_val();
std::cou...
Priyansh Jain
Votes: 0
Answers: 1
How to commit changes through reference from vector into that vector in C++?
Having this:
#include <iostream>
#include <vector>
class A{
std::vector<std::string> vec;
public:
std::string &save(std::string const&s){
vec.push_back(s);
...
milanHrabos
Votes: 0
Answers: 1
C++: Pass string literal or variable to function
I have a function f that takes a string as input. I usually want to provide a string literal, e.g., f("hello"). However, I want to implement another function g that builds upon f:
std::strin...
Green绿色
Votes: 0
Answers: 2