Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ overloading by ref-qualifiers

#include <stdio.h>

class My {
public:
    int get(int) & { // notice &
        printf("returning int..
");
        return 42;
    }
    char get(int) && { // notice &&
        printf("returning char..
");
        return 'x';
    };
};

int main() {
    My oh_my;
    oh_my.get(13); // 'oh_my' is an lvalue
    My().get(13); // 'My()' is a temporary, i.e. an rvalue
}
Comment

c++ overloading by ref-qualifiers

#include <stdio.h>

class My {
public:
    int get(int) & { // notice &
        printf("returning int..
");
        return 42;
    }
    char get(int) && { // notice &&
        printf("returning char..
");
        return 'x';
    };
};

int main() {
    My oh_my;
    oh_my.get(13); // 'oh_my' is an lvalue
    My().get(13); // 'My()' is a temporary, i.e. an rvalue
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: logisch oder 
Cpp :: check if cin got the wrong type 
Cpp :: bit masking tricks 
Cpp :: fname from FString 
Cpp :: java to puthon converter 
Cpp :: expresiones regulares español 
Cpp :: HMC 5883 Example to return x y z values 
Cpp :: even or odd program in c++ 
Cpp :: pointers in cpp 
Cpp :: how to scan vector in c++ 
Cpp :: top array data structure questions in inteviews 
Cpp :: convert hex to decimal arduino 
Cpp :: whatsup 
Cpp :: void setup() { // put your setup code here, to run once:in m}void loop() { // put your main code here, to run repeatedly:} 
Cpp :: const in c++ is same as globle in python 
Cpp :: c++ restrict template types 
Cpp :: c to c++ code converter 
Cpp :: Opengl GLFW basic window 
Cpp :: big o notation practice c++ 
Cpp :: sjfoajf;klsjflasdkfjk;lasjfjajkf;dslafjdjalkkkjakkkkkkkkkkkkkkkkfaWZdfbhjkkkk gauds 
Cpp :: Nested ternary operator C++ 
Cpp :: foo foo little dogs 
Cpp :: file is good in c++ 
Cpp :: default order in set in c++ 
Cpp :: converting a string to lowercase inbuld function in cpp 
Cpp :: c++ find unused class methods 
Cpp :: pros millis() 
Cpp :: days in a year c++ 
Cpp :: 01matrix 
Cpp :: convert preorder to postorder calculator 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =