while assigning on object to another,
default assignment operator written by compiler
makes memberwise copying that why there isn't any problem with
types like (int ,double etc) but it cannot copy strings, these are ok.
what i dont understand is how it can manage assigning arrays.
let me explain with an example:
val1 --> A.val1= B.val1 this is valid and ok for me
str ---> A.str=B.str this is invalid and ok for me
array--> A.array=B.array this is valid but how? and why?
default assignment operator written by compiler
makes memberwise copying that why there isn't any problem with
types like (int ,double etc) but it cannot copy strings, these are ok.
what i dont understand is how it can manage assigning arrays.
let me explain with an example:
Code:
class myClass {
int val1;
char *str;
int array[5];
};
myClass B; // create object B
myClass A=B; // initialize object A with object B
str ---> A.str=B.str this is invalid and ok for me
array--> A.array=B.array this is valid but how? and why?
Comment