开发者

C++ Need Help with Displaying Results in Main() DEBUGGING

Hey everyone here is my code

ive tried to display my results with no luck

i get an error

count was not declared in this scope

    int main()
    {
        CircularList<int> channelList(0);
        cout << "Value Stored: " << channelList.GetValue() << endl;  <--- OVER HERE
}

Can some please help me display my results, or provide a solution much grateful

here is the rest of my program

/*
 *  CircularList.h
 *       *
 *  Created by  on 30/08/11.
 *  Copyright 2011 ____. All rights reserved.
 *
 */

#ifndef _CIRCULARLIST_CPP_
#define _CIRCULARLIST_CPP_
#include<iostream>
#include<string>
#include<cctype>
#include "CircularList.h"


template<class T> CircularList<T>::CircularList(T emptyValue) {
    m_EmptyValue = emptyValue;
    m_CurrentNode = NULL;
}

template<class T> void CircularList<T>::InsertBefore(T data) {
    if(m_CurrentNode == NULL) {
        m_CurrentNode = new ListNode<T>();
        m_CurrentNode->value = data;
        m_CurrentNode->next = m_CurrentNode;
        m_CurrentNode->previous = m_CurrentNode;
        return;
    }

    ListNode<T>* tempNode = new ListNode<T>();
    tempNode->next = m_CurrentNode;
    tempNode->previous = m_CurrentNode->previous;
    m_CurrentNode->previous->next = tempNode;
    tempNode->value = data;
    m_CurrentNode->previous = tempNode;
    m_CurrentNode = tempNode;
}

template<class T> void CircularList<T>::InsertAfter(T data) {
    if(m_CurrentNode == NULL) {
        m_CurrentNode = new ListNode<T>();
        m_CurrentNode->value = data;
        m_CurrentNode->next = m_CurrentNode;
        m_CurrentNode->previous = m_CurrentNode;
        return;
    }

    ListNode<T>* tempNode = new ListNode<T>();
    tempNode->previous = m_CurrentNode;
    tempNode->next = m_CurrentNode->next;
    m_CurrentNode->next->previous = tempNode;
    tempNode->value = data;
    m_CurrentNode->next = tempNode;
    m_CurrentNode = tempNode;
}

template<class T> T CircularList<T>::GetValue() {
    if(m_CurrentNode == NULL) return m_EmptyValue;
    return m_CurrentNode->value;
}

template<class T> T CircularList<T>::NextValue() {
    if(m_CurrentNode == NULL) return m_EmptyValue;
    m_CurrentNode = m_开发者_运维问答CurrentNode->next;
    return m_CurrentNode->value;
}

template<class T> T CircularList<T>::PreviousValue() {
    if(m_CurrentNode == NULL) return m_EmptyValue;
    m_CurrentNode = m_CurrentNode->previous;
    return m_CurrentNode->value;
}

template<class T> CircularList<T>::~CircularList() {
    while(m_CurrentNode->next != m_CurrentNode && m_CurrentNode->previous != m_CurrentNode) {
        ListNode<T>* prevNode = m_CurrentNode->previous;
        ListNode<T>* nextNode = m_CurrentNode->next;

        prevNode->next = nextNode;
        nextNode->previous = prevNode;

        delete m_CurrentNode;
        m_CurrentNode = nextNode;
    }

    delete m_CurrentNode;
    m_CurrentNode = NULL;
}

    int main()
    {
        CircularList<int> channelList(0);
        cout << "Value Stored: " << channelList.GetValue() << endl;
}

#endif


I strongly suspect one of the following:

  • you have mistyped cout as count in your actual code.
  • you have mistyped cout as count in the error message that you provided above, and you haven't got a using namespace std; or using std::cout; in your actual code. (Alternatively, you can just fully qualify cout, as std::cout.)

[Note: never do using namespace XXX; in a header file.]


you must qualify the scope of std::cout, like so:

    std::cout << "Value Stored: " << channelList.GetValue() << std::endl;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜