Hi, I'm having this question and i can't figure out the right answer
What operations may be invoked implicitly for a class object
So there are these 7 essential operations as i read in my book
1. Constructors from one or more arguments
2. Default constructor
3. Copy constructor (copy object of same type)
4. Copy assignment (copy object of same type)
5. Move constructor (copy object of same type)
6. Move assignment (copy object of same type)
7. Destructor
Also i understood that if we don't make constructor with 1 argument explicit we can initialize object like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
struct X{
int val = 0;
X() = default;
X(int i):val{i}{}
};
void print_X(X x){
cout << x.value;
}
int main(){
X new_X = 9; //instead of X new_X{9};
print_X(12); // also works
}
both X new_X = 9; and print_X(12); stop working if i make X(int i):val{i}{} to be explicit.
But i see author was asking "What operations..." so there must be more of them. How could i use rest of them implicitly and explicitly?