佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 958|回复: 1

帮帮忙!C++问题

[复制链接]
发表于 15-10-2008 12:56 AM | 显示全部楼层 |阅读模式
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <fstream.h>
using namespace std;

class nodeStack
{
public :
  string name,ID,type;
  nodeStack * next;
};

class stack
{
  private:
   nodeStack * Top;
   
  public:
   void create();
   void push(string a, string b, string c);
   nodeStack* pop();
   string stackTop();
   bool isEmpty();
   nodeStack* search(string a, nodeStack* data);
};

void stack::create()
{
Top = NULL;
}

bool stack::isEmpty()
{
return bool (Top == NULL);
}

void stack::push(string a, string b, string c)
{
     nodeStack* newnode;
     newnode->name = a;
     newnode->ID = b;
     newnode->type = c;
     newnode->next = Top;
     Top = newnode;
}

nodeStack* stack::pop()
{
     nodeStack* node;
     node = Top;
     Top = Top->next;
     return node;
}

nodeStack* stack::search(string a, nodeStack* data)
{
if ( a == data->ID)
{  return data;    }
}
     


int main()
{
    stack list;
    int num = 1;
    string a, b, c,srh;
    nodeStack* newnode;
    nodeStack* newdata;
    nodeStack* searchnode;
   
    list.create();
    ifstream input ("abac.txt");
   
    for (int i=0; i<25; i++)
    {
          input >> a;
          input >> b;
          input >> c;
          list.push(a,b,c);
    }  
   
    nodeStack* data[num];
   
    for (int i=0; i
    {
        newnode = list.pop();
        data = newnode;
    }
    cout<< "Please enter the ID you want to search for :";
    cin >>srh;
   
    for(int i=0; i
    {
     data = newdata;
     searchnode = list.search(srh,newdata);
    }
    cout<<"Name :"<name<<<"ID :"<ID<<<"Phone Type:"<type<
   
    getch();
    return 0;
}


没法run!!请那位大大来帮忙....


[ 本帖最后由 悲哀河川 于 15-10-2008 12:58 AM 编辑 ]
回复

使用道具 举报


ADVERTISEMENT

发表于 16-10-2008 12:00 AM | 显示全部楼层
cout<<"Name :"<name<<<"ID :"<ID<<<"Phone Type:"<type<
   
name, id, type 从何处来? id? list.id ?

还有,
void stack::push(string a, string b, string c)
{
     nodeStack* newnode;
     newnode->name = a;
     newnode->ID = b;
     newnode->type = c;
     newnode->next = Top;
     Top = newnode;
}

nodeStack* newnode; ?? newnode 只是一个pointer, 她指向哪里?你要的应该是pop, 应该是
     nodeStack* newnode = new notestack; 吧?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 23-12-2025 05:13 AM , Processed in 0.103757 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表