Re: Program to find occurences of a word in a file
On Nov 23, 9:31 pm, "Tadeusz B. Kopec" <tko...@NOSPAMPLEASElife.pl>
wrote:
On Fri, 23 Nov 2007 04:06:38 -0800, terminator wrote:
all what I get is that in case of default constructing ,intrinsic
rvalues go zero.
#include <iostream>
#include <conio.h>
using namespace std;
template <typename T> struct testd{
T t;
testd():t(){};
};
int main(){
testd<long> tl, *ptr=new testd<long> ; cout <<"One\n"<< tl.t << endl;
cout <<"Two\n"<< ptr->t << endl;
delete ptr;
cout <<"Three\n"<< long() << endl;
long* l=new long;
cout <<"Four\n"<< l << endl;
new(l)long();
cout <<"Five\n"<< l << endl;
delete l;
cout<<"Six\n" << testd<long>().t <<endl;
getch();
return 0;
};
only the third output comes zero.
so in case the container uses placement new nop is done and it cannot
zero-default the value.
now I believe that it is the default allocator - not the ctor - who
resets the allocated bytes to zero .
Well, I tried it by myself and in all except fourth and fifth I got zero.
When I changed fourth and fifth to print pointee instead of pointer I
also got zeroes.
silly me. but derefrencing did not zero mine.
best,
FM.