[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

RE: [PROGRAMMERING] C++ problem , allokering



Går det også galt uden debug?
hvordan checker du at new går godt?
hvis du laver 2 CELL_DEBUG("Bond Atom 1 A:" << *a1); lige efter hinanden er den så gal?

Lidt famlen omkring:
hvordan ser din copy constructor ud?
har du overstyret noget andet? 
bruger du call by referance i CELL_DEBUG?
er referancen const?


> -----Original Message-----
> From: Rune Larsen [mailto:sslug@sslug 
> Sent: 21. april 2005 13:52
> To: sslug@sslug
> Subject: [PROGRAMMERING] C++ problem , allokering
> 
> 
> Hej alle 
> jeg sidder med et problem i c++ som jeg ikke helt kan hitte
> ud af. Jeg skal oprette et objekt der tager en pointer til
> et array som argument. Problemet er at de objekter jeg skal
> indsætte i array'et ændre sig når jeg allokerer array'et 
> med new. En del af metoden jeg har problemer med står 
> herunder.
> 
> snip...
> AtomLight* a1 = extract_atomlight(*atom_index_1);
> AtomLight* a2 = extract_atomlight(*atom_index_2);
> snip...
> if(vector_norm_3(dist) < bond_dist){
>         if(atom_index_1->this_cell == LOCAL_CELL){
>                 // ####### HER GÅR DET GALT !!!!!!! #####
>                 CELL_DEBUG("Bond Atom 1 A:" << *a1);
>                 CELL_DEBUG("Bond Atom 2 B:" << *a2);
>                 AtomLight *pair = new AtomLight[2];
>                 CELL_DEBUG("Bond Atom 1 :" << pair[0]);
>                 CELL_DEBUG("Bond Atom 2 :" << pair[1]);
>                 CELL_DEBUG("Bond Atom 1 A:" << *a1);
>                 CELL_DEBUG("Bond Atom 2 B:" << *a2);
>                 // ########### HERTIL #############
>                 pair[0]=*a1;
>                 pair[1]=*a2;
>                 bonded_list[no_of_bonds++].insert(proxy_data,pair);
> snip...
> 
> ovenstående kode giver følgende output. (CELL_DEBUG er en 
> "cout"-macro)
> læg mærke til at positionerne for "Bond Atom 1 A:" ændre sig 
> efter at new er blevet kaldt .. hvad sker der ? 
> snip ...
> Cell index (1,1,0) :    Bond Atom 1 A:AtomLight index: 1, 
> advtype: 34 positions: (-9.3e-12,-1.143e-10,9.15e-11)
> Cell index (1,1,0) :    Bond Atom 2 B:AtomLight index: 3, 
> advtype: 17 positions: (7.52e-11,-1.722e-10,7.64e-11)
> "HER BLIVER new KALDT "
> Cell index (1,1,0) :    Bond Atom 1 :AtomLight index: 0, 
> advtype: 0 positions: (0,0,0)
> Cell index (1,1,0) :    Bond Atom 2 :AtomLight index: 0, 
> advtype: 0 positions: (0,0,0)
> Cell index (1,1,0) :    Bond Atom 1 A:AtomLight index: 1, 
> advtype: 34 positions: (0,0,0)
> Cell index (1,1,0) :    Bond Atom 2 B:AtomLight index: 3, 
> advtype: 17 positions: (7.52e-11,-1.722e-10,7.64e-11)
> snip...
> 
> hilsen rune 
> 


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *