I know that when creating derived classes in C++ a structure like this:
class A {
...
}
class B: public A {
...
}
Would mean that there is a relation ship between A and B such that B "is a" A. I am wondering what if I wanted an A-B relationship such that B has a A not that B is a A.
My objective is to write a code that computes wave-function and corresponding properties of that wave-function for a particular molecule. I want my molecule to have a wave-function object. Can I i just create the molecule and wave-function classes separately, and then call the wave-function constructor in the molecule constructor?
class Molecule {
Molecule(...);
Molecule::Molecule(...)
{
wavefunction WF(...);
}
};
IF i can do this is it the correct way to create this has-a relationship? How would I access the wave-function object? Like this:
mol.WF
assuming I had created a molecule with the name mol. This is my first whack at a program with more than one custom class and I am confusing myself very fast.