无法在Mac上的代码块上运行C ++程序

时间:2014-11-20 12:34:22

标签: c++ macos codeblocks

这是构建日志所说的内容:

-------------- Build: Debug Win32 in CMP305LA7E1Solns (compiler: GNU GCC Compiler)---------------

Target is up to date.
Nothing to be done (all items are up-to-date).
-------------- Run: Debug Win32 in CMP305LA7E1Solns (compiler: GNU GCC Compiler)---------------

Checking for existence: /Users/abdulrahmanosoble/Documents/Programming/CMP 305-LA7-F14-Code for students/CMP305LA7Solns/CMP305LA7E1Solns/CMP305LA7E1Solns
Executing: /Users/abdulrahmanosoble/Documents/Programming/CMP\ 305-LA7-F14-Code\ for\ students/CMP305LA7Solns/CMP305LA7E1Solns/CMP305LA7E1Solns  (in /Users/abdulrahmanosoble/Documents/Programming/CMP 305-LA7-F14-Code for students/CMP305LA7Solns/CMP305LA7E1Solns/.)
Process terminated with status -1 (0 minute(s), 0 second(s))

我点击运行,没有弹出终端窗口。没有输出窗口。只是那个构建日志。谷歌一直没有帮助。任何帮助将不胜感激。

编辑:代码: TEST.CPP:

#include <iostream>
#include "dll.h"
#include "dll.cpp"

    int main()
{
    DoublyLinkedList<int> s;
    s.InsertItem(3);
    s.InsertItem(4);
    cout<<"Length of s: "<<s.LengthIs();
}

dll.h:

#ifndef dll_h
#define dll_h
#include <iostream>
using namespace std;
template <class ItemType>
struct NodeType
{
  ItemType info;
  NodeType* next;
  NodeType* back;
};


template <class ItemType>
class DoublyLinkedList
{
public:
  DoublyLinkedList();     // Class constructor.
  ~DoublyLinkedList();    // Class destructor.

  ////////// implement these functions //////////
  DoublyLinkedList(DoublyLinkedList<ItemType>& );
  void InsertItem(ItemType item);
  void DeleteItem(ItemType item);


  void FindItem(NodeType<ItemType>* listData, ItemType item, NodeType<ItemType>*& location, bool& found);
  int LengthIs() const;
  void MakeEmpty();
  void RetrieveItem(ItemType& item, bool& found);
  void ResetList();
  void GetNextItem(ItemType& item);

private:
  NodeType<ItemType>* listData;
  int length;
  NodeType<ItemType>* currentPos;
};
#endif

dll.cpp:

#include "DLL.h"
template<class ItemType>
 DoublyLinkedList<ItemType>::DoublyLinkedList()
 {
     listData = NULL;
     length =0;
     currentPos = NULL;

 }
template<class ItemType>
void DoublyLinkedList<ItemType>::FindItem(NodeType<ItemType>* listData, ItemType item,
     NodeType<ItemType>*& location, bool& found)
// Assumption: ItemType is a type for which the operators "<" and
//  "==" are defined-either an appropriate built-in type or a
//  class that overloads these operations.
// Pre:  List is not empty.
// Post: If there is an element someItem whose key matches item's
//       key, then found = true; otherwise, found = false.
//       If found, location contains the address of someItem;
//       otherwise, location contains the address of the logical
//       successor of item.
{
  bool moreToSearch = true;

  location = listData;
  found = false;
  while (moreToSearch && !found)
  {
    if (item < location->info)
      moreToSearch = false;
    else if (item == location->info)
      found = true;
    else
    {
      location = location->next;
      moreToSearch = (location != NULL);
    }
  }
}


template <class ItemType>
int DoublyLinkedList<ItemType>::LengthIs() const
{
  return length;
}

template <class ItemType>
void DoublyLinkedList<ItemType>::MakeEmpty()
// Post: List is empty; all items have been deallocated.
{
  NodeType<ItemType>* tempPtr;

  while (listData != NULL)
  {
    tempPtr = listData;
    listData = listData->next;
    delete tempPtr;
  }
  length = 0;
}

template <class ItemType>
void DoublyLinkedList<ItemType>::ResetList()
{
  currentPos = NULL;
}

template <class ItemType>
void DoublyLinkedList<ItemType>::GetNextItem(ItemType& item)
{
  if (currentPos == NULL)
    currentPos = listData;
  else
    currentPos = currentPos->next;
  item = currentPos->info;
}

template <class ItemType>
void DoublyLinkedList<ItemType>::RetrieveItem(ItemType& item,
     bool& found)
{
  bool moreToSearch;
  NodeType<ItemType>* location;

  location = listData;
  found = false;
  moreToSearch = (location != NULL);

  while (moreToSearch && !found)
  {
    if (location->info < item)
    {
      location = location->next;
      moreToSearch = (location != NULL);
    }
    else if (item == location->info)
    {
      found = true;
      item = location->info;
    }
    else
      moreToSearch = false;
  }
}

template <class ItemType>
 DoublyLinkedList<ItemType>:: ~DoublyLinkedList()    // Class destructor.
 {
     MakeEmpty();
 }

 template <class ItemType>
 void DoublyLinkedList<ItemType>::InsertItem(ItemType item)
 {
     NodeType<ItemType>* node = new NodeType<ItemType>;
     node->info = item;
     if(!length)
     {
         listData = node;
         node->next = NULL;
         node->back = NULL;
         length++;
         return;
     }
     NodeType<ItemType>* temp =listData;
     while(temp != NULL && node->info > temp->info)
         temp=temp->next;
     node->next = temp;
     node->back = temp->back;
     temp->back = node;
     node->back->next = node;
     length++;
}

0 个答案:

没有答案