how to access variable in different class

Oct 22, 2014 at 2:15am
someone please help! how can I make the queue of type pcb

and how to access pid in other clases?
Last edited on Oct 22, 2014 at 4:24pm
Oct 22, 2014 at 2:16am
inheritance or make pid public and include class PCB in header
Last edited on Oct 22, 2014 at 2:17am
Oct 22, 2014 at 2:23am
okay I did this and included pcb.h in header file, still not working.
1
2
3
4
class PCB{
	public:
		int pid;
};


I'm trying to access it in functions of ready_queue.
Last edited on Oct 22, 2014 at 2:25am
Oct 22, 2014 at 2:41am
//
Last edited on Oct 22, 2014 at 4:24pm
Oct 22, 2014 at 2:46am
You cant access non static members like that..You have to return it by an object or make pid static..my previous answer was a bit incomplete..To put it plainly..all class members must be accesses through the class
Last edited on Oct 22, 2014 at 2:49am
Oct 22, 2014 at 2:49am
okay I made it static int *pid but still not declared in scope.
Oct 23, 2014 at 3:23am
solve the scope issue, include class for pid, call by classname.pid/classname->pid or by getter method ?
Last edited on Oct 23, 2014 at 3:25am
Topic archived. No new replies allowed.