Pergunta

Has any one encountered this before and found a fix? or am I doing something wrong? If i try to access the head or tail nodes in the outer class intellisense says they have no members.sorry if its a bit of a mess, I have been troubleshooting it for awhile now.

Edit: I have tried with MS VS 2010, & 2012

#pragma once

#include <string>
using namespace std;

template <typename ItemType>
class LinkedArrayList
{
public:
    /*************************************
            Inner Class
    *************************************/
    class Node 
    {
    public:
        Node(void){};
        Node(Node* pNode, Node* nNode, int limit)
        {
            prevNode = pNode;
            nextNode = nNode;
            capacity = limit;
            size = 0;

            if(capacity != 0)
                items = new ItemType[capacity];
        };
        ~Node(void)
        { 
            delete(items);
        };
        Node* nextNode;
        Node* prevNode;
        ItemType* items;
        int size;
        int capacity;
    private:
    };

    /*************************************
            Declarations
    *************************************/
    int numOfNodes;
    int arrayCapacity;
    Node* head;
    Node* tail;

    /*************************************
            Functions
    *************************************/

    LinkedArrayList(void)
    {
    };
    LinkedArrayList(int capacity)
    {
        head = new Node(NULL, NULL, 0);
        tail = new Node(NULL, NULL, 0);
        arrayCapacity = capacity;
        numOfNodes = 0;
    };

    ~LinkedArrayList(void)
    {
    };

when I try to type head-> or tail-> the tip in the bottom left hand corner says intellisense no members available

Foi útil?

Solução

The members of a class are private by default. To make them accessible use keyword public.

class X
{
public:
    X() {}
    ~X() {}
    // rest of the public stuff
private:
    // private stuff
};

Inner class has full access to private members of outer class, not other way around.

Do not pay too much attention to what intellisense says; it is often helpful, but it is sometimes wrong. Compiler is written by better programmers of Microsoft so try if what you wrote compiles.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top