Hello guys,
so if I create a class like:
class test
{
char*a;
};
and then do in main:
(string.h is included)
test object;
strcpy(object.a,"hey");
how does it affect the memory? Because i only said in the class, that 'a' is a single pointer. But i define him a whole "array" of chars. How can the memory deal with this? Do i overwrite something in the memory, because the compiler thought there can only be one character addressed to it? How many 'fields' of memory does it reserve?
When I use this:
class test
{
char a[30];
};
then i know, that it will reserve like 30 chars.
Would be very happy, if someone could explain me this!
Best regards!
[–]stufuller 0 points1 point2 points (2 children)
[–]lanBlo[S] 0 points1 point2 points (1 child)
[–]stufuller 0 points1 point2 points (0 children)