Howdy, so I'm created a class and I either want to have that class constructor take in that an object that was created in another or one of its functions take in the object.
This is an example(above) of an object I've created in one of my classes. Id like my Chics Class to take in that Charm, Str, and Intel info from the class above and then use it in functions.
1 2 3 4 5 6
class Chics
{
public:
Chics();
Chics(const Engineer& );
void judge(Engineer&, int ,int ,int );
My initial idea but this isnt working at all. Theres other information stored in the objects but i just want to take those three ints from the object thats been created already. Help appreciated.
I don't understand the problem. You pass in an const Engineer& as an argument to the Chics class contructor. Then, you use some public interface(e.g. Engineer::GetCharm()) to get these values from Engineer.
@MatthewRock Issue is, I was wanting to use the Chics Object or one its funcions to use the values in inside Engineer, to create some type of score that I can use to decide whether or not a player gets the "Chics numbers". If theres some other way to pass the values already held in Engineer, then im fine with doing that also. Just need to pointed in the direction of how.
You haven't really provided enough context. What is missing is an understanding of the relationship between the two classes.
I see that Chics has a constructor that takes an Engineer. This seems to imply that Chics HAS A Engineer member. IS A Chics an Engineer? If so, this would usually imply inheritance.
If there is not a IS A or a HAS A relationship, then you've already been given the suggestion to provide getters in the Engineer class for the three member variables you're interested in and then call those getters to access the member variables.
@MikeyBoy @AbstractionAnon
The Relationship looks like this. I have a Bros Class, and then there are 3 type of Bros class that derive from it, Engineer, Jock, Artsy. I also have a club class where most of the data processing takes place. As shown below.