Weird errors, please help.

This is a discussion on Weird errors, please help. within the C++ Programming forums, part of the General Programming Boards category; Hi, Can someone please tell me how to fix this code? I can't continue till it is figured out. Thank ...

The problem seems to be that the Position class has its own errors (as I pointed out). In addition, outside the declaration of the outer class, you should always refer to the inner class as outer::inner.

Both MingW and Comeau Online were quite happy to compile it once these errors were fixed, even if you use a forward declaration of Position.

What exactly is wrong with the position class? If I put the vector in the position class will I be able to access it with CompTree functions? Just to clarify I making a complete binary tree that holds ints and then making a heap with a heap sort function to sort a list of ints. I'm sorry for all these questions but this is for my data strutures class where the teacher is making us learn C++ for the first time as well as data structures so thats why I am very frustrated. Thanks for your time.

What exactly is wrong with the position class? If I put the vector in the position class will I be able to access it with CompTree functions? Just to clarify I making a complete binary tree that holds ints and then making a heap with a heap sort function to sort a list of ints. I'm sorry for all these questions but this is for my data strutures class where the teacher is making us learn C++ for the first time as well as data structures so thats why I am very frustrated. Thanks for your time.

The usual rules for accessing members of the outer class apply to nested classes too. You can't access a non-static member without an instance.

You could do lots of things, such as passing a const reference of the vector to the methods of Position that need to know it. Or you could just call getRank and access the vector at that index outside Position

Let's clarify here:
A class is a blueprint. Let's say a car blueprint. You can't drive a car blueprint, can you? No. First, someone must make a car from a blueprint. This is called an instance of that class. An instance of a car from the car blueprint in this example.Then you can drive that car.
The member "v" is not a part of Position; it's a part of another class, so you can't use it directly. Because the instance of Position will try to access "v" from a blueprint, which you can't do, can you? There must be an instance of that blueprint from where you can access "v," or alternatively, "v" could be moved inside Position in which case it would work since "v" is part of the Position blueprint, then "v" would exist inside the instance of the object created from the blueprint.