How to make my class globally accessible
ok
i don't know how to deal with this one. I have a class like this:
file one :
Code:
class X : public Y {
public:
virtual int query(int, int);
// constructor
X(int, int);
~X();
private;
int *M
int *N
}
file two:
Code:
class Y {
public:
// returns index of RMQ[i,j]
virtual int query(int, int) = 0;
};
And i construct my M and Nby calling :
and afterwords by calling
i get my result. The problem is I need to be able to call result = Y (c,d) from outside my main function and get results but i don't know how to do this.
So I want to be able to do something like this.
Code:
#include <iostream>
int g;
void func2(int *h){
*h = g;
}
void func(int *g){
*g = 1;
}
void func1(int f){
g = f;
}
int main ()
{
func(&g);
int p = 7;
func1(p);
int h ;
func2(&h);
std::cout << h << std::endl;
return 0;
}
however i have no clue how to do this with classes.
thank you
baxy