"Good Guy" <> wrote in message
news:d7116df9-7ffc-44fe-992f-...
>
> I have two following lines of code at global scope:
>
> const Cont<12> container={"hello world"};
> ArrayToUse<11> temp(container);
> char (&charArray)[11]=temp.container.charArray;
>
> In totality of my code The only usage of "container" object is for
> initialization of an object of "ArrayToUse" class as mentioned and
> after initialization of "charArray" reference to
> "temp.container.charArray" I'll use that reference in rest of my code,
> now I'm wondering whether after building the code memory will be
> reserved for "container" object or not since that's got a temporary
> usage.
Since it's a global object, the object's life time is not limited.
You can define in any other compilation unit "extern const Cont<12>
container;" and reference this object. The compiler cannot know this while
compiling the compilation unit where you define container, temp and
charArray.
Helge
|