I'm new to C++ and not an experienced programmer.
I have a class which contains a member variable of another class I have created. I want this variable to be passed through by the user in the constructor. However, the variable calls its constructor the second it is initialised. How do I prevent this from happening
class Cypher {
private:
// This definition calls the constructor, I dont want this, i want an
// it to be an instance or a copy of the variable sent through in this classes constructor
KeyCreator key;
public:
Cypher(KeyCreator key) {
key = key;
}
}
Any help is much appreciated, I really have tried searching but can't find anything. I must be using incorrect terms.