| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 388 人关注过本帖
标题:编译出错,大家帮忙看看啊。
只看楼主 加入收藏
zd123
Rank: 2
等 级:论坛游民
帖 子:43
专家分:33
注 册:2009-9-4
结帖率:70%
收藏
已结贴  问题点数:20 回复次数:1 
编译出错,大家帮忙看看啊。

1>d:\竹林晚风\documents\visual studio 2008\projects\qqq\qqq\qqq.cpp(54) : error C2109: 下标要求数组或指针类型
1>d:\竹林晚风\documents\visual studio 2008\projects\qqq\qqq\qqq.cpp(54) : error C2228: “.output”的左边必须有类/结构/联合


// qqq.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
using namespace std;
class Book
{
private:
    char name[100];
    char num[20];
    char abstracts[100];
public:
    void input()
    {
        cout<<"Please input the name of the book:"<<endl;
        cin>>name;
        cout<<"Please input the num of the book:"<<endl;
        cin>>num;
        cout<<"Please input the abstract of the book:"<<endl;
        cin>>abstracts;
    }
    void output()
    {
        cout<<"The name of the book is :"<<name<<endl;
        cout<<"The num of the book is :"<<num<<endl;
        cout<<"The abstract of the book is :"<<abstracts<<endl;
    }
};
class Student
{
private:
    char name[100];
    char ID[50];
    Book a[5];
public:
    void inputs()
    {
        cout<<"Please input the name of the student :"<<endl;
        cin>>name;
        cout<<"Please input the ID of the student :"<<endl;
        cin>>ID;
    }
    void inputb(int i)
    {
        a[i].input();
    }
    void outputs (int a)
    {
        cout<<"The name of the student is :"<<name<<endl;
        cout<<"The ID of the student is:"<<ID<<endl;
        for (int j=0;j<a;j++)
        {
            a[j].output();
        }
    }
};



int _tmain(int argc, _TCHAR* argv[])
{
    Student stu;
    stu.inputs ();
    cout<<"Do you want to borrow a book?"<<endl;
    char s;
    cin>>s;
    int k=0;
    while (s=='Y'||s=='y')
    {
        
        stu.inputb(k);
        k++;
        if(k==5)
        {
            cout<<"you can't borrow a book more!"<<endl;
            break;
        }
    }
    cout<<"The massage you inputed are:"<<endl;
    stu.outputs (k);


    return 0;
}

搜索更多相关主题的帖子: 编译 
2009-12-02 23:03
flyingcloude
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:6
帖 子:598
专家分:1512
注 册:2008-1-13
收藏
得分:20 
程序代码:
void outputs (int a)  //a改成用其他的字母
    {
        cout<<"The name of the student is :"<<name<<endl;
        cout<<"The ID of the student is:"<<ID<<endl;
        for (int j=0;j<a;j++)
        {
            a[j].output();
        }
    }


你能学会你想学会的任何东西,这不是你能不能学会的问题,而是你想不想学的问题
2009-12-02 23:18
快速回复:编译出错,大家帮忙看看啊。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011604 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved