How is this an "Access Violation"

Rene Zwanenburg renezwanenburg at gmail.com
Tue Oct 27 12:05:33 UTC 2020


On Tuesday, 27 October 2020 at 02:05:37 UTC, Ruby The Roobster 
wrote:
>        void construct(string type,atom base,atom bonded)
>         {
>         base = new 
> atom(base.name.idup,base.mass,base.electro_negativity,base.valence_electrons,base.electrons,base.protons,base.neutrons,base.pos);
>         (...)
>             assert(this.base.valence >= 1 && 
> this.bonded.valence >=1 && this.base.electro_negativity >= 0 && 
> this.bonded.electro_negativity >= 0,"For a single bond, both 
> atoms need to have at least one free electron and have to have 
> electro negativity.");

Going by the assert this is a member function of a class or 
struct with base and bonded members. I think you meant to assign 
the newly created atoms to those fields instead of overwriting 
your arguments.


More information about the Digitalmars-d-learn mailing list