注册 登录
编程论坛 VC++/MFC

小弟 被这问题困扰N久,请各位大侠帮忙解决下,感激不尽。。。。

书生小白 发布于 2011-06-15 10:58, 696 次点击
using namespace std;
#include <string>
#define NULL 0
class stu
{
private:
    int num;
    string name;
public:
    void display();

};
void display();
void play(class stu *p);
class stu *head=NULL;
int main()
{
    display();
    return 0;
}
void stu::display()
{
    class stu *p1;
    p1=new stu;
    cout<<"请输入学生信息"<<endl;
    cin>>p1->num;
    cin>>p1->name;
    play(p1);
}
void play(class stu *p)
{
    string name;
    class stu *p1;
    cin>>name;
    while(strcmp(name,p->name)==0)
    {
        cout<<p->num<<endl;
        cout<<o->name<<endl;
    }
}
6 回复
#2
yuccn2011-06-15 20:30
什么问题都不问
就发一大堆的代码。。。
#3
try_catch2011-06-17 03:40
your class stu contains two private fields "num" and "name", but you used those two private fields outside the class directly.
the worst and fastest way to fix your code is changing "num" and "name" to public.

Also I don't know why you declare p1 in play function. BTW...your code has mem leak.
#4
Toomj2011-06-17 09:41
回复 3楼 try_catch
大牛啊··············
#5
try_catch2011-06-17 10:08
回复 4楼 Toomj
过奖?
#6
书生小白2011-06-17 11:07
大哥,也不要用英文啊,你想表达个扫描东西啊。。。。大哥,也不要用英文啊,你想表达个扫描东西啊。。。。
#7
sexywolfcrak2011-06-18 21:39
牛人还真多
1