Now let's say I have a second class in a header file.
Header.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#ifndef HEADER_H_
#define HEADER_H_
#include <iostream>
class anotherClass
{
public:
int i = Application.integer; // I know this won't work.
}
#endif
{
What I'm trying to do is access functions, variables, and pointers of one class from an entirely different class. I know that I can call functions by making them static and using "class_name::function();" but I haven't been able to figure out variables and pointers.
There may be mistakes in the code above, as I just wrote it. This isn't the exact code I'm working with, as it would be too long and complex to reasonably ask a question about here. However, it gets the idea across.
Are you talking about something like in one file you have an instance of a class called Application and in another file you want to be able to get stuff from that instance? Or do you just want a class to be able to get stuff that type of class in general?
I just need to pass variables between classes. The only reason I posted my Application class as being separated into a header and a main was because that's the structure my actual application follows, even though it will probably not affect the solution.
In my actual application, I have a pointer to an object (declared in my main class) that I want to be able to access from several different classes.
let me see if I understand you correctly:
For example:
You have two classes A and B.
You want to pass an object of class A to a member function of an object of class B and have class B have access to ALL of class A's private as well as public members/functions?