标题:大家看看哪出错了,很简单的!
取消只看楼主
cuixing158
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-9-8
结帖率:100%
已结贴  问题点数:20 回复次数:2 
大家看看哪出错了,很简单的!
#include <iostream>
#include<string>
using namespace std;
class Student
{
private:
    int number;
    char name[20];
    char sex;
    int age;
public:
    void set(int a,char *b,char c,int d);
    void show();
};
void Student::set(int a,char *b,char c,int d)
    {
        number=a;
        strcpy(name,b);
        sex=c;
        age=d;
    }

    void Student::show()
    {
        cout<<number<<'\t'<<name<<'\t'<<sex<<'\t'<<age<<endl;

    }
怎么就错了呢,程序都是教材上面的
搜索更多相关主题的帖子: private include public number 
2014-09-08 16:32
cuixing158
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-9-8
得分:0 
回复 2 楼 richardw
咦?我的咋链接出错,用你的主函数也这种错误
我的主函数是
int main()
{
    Student stu1,stu2;
    Student *p;
    p=&stu1;
    stu1.set(101,"zhao",'m',22);
    stu2.set(102,"qian",'f',21);
    stu1.show();
    stu2.show();

    return 0;
}
错误提示:
--------------------Configuration: example2 - Win32 Debug--------------------
Compiling...
example2.cpp
D:\my_c_documents\example\example2.cpp(31) : error C2511: 'calc_pt' : overloaded member function 'void (void)' not found in 'line'
        D:\my_c_documents\example\example2.cpp(9) : see declaration of 'line'
example3.cpp
D:\my_c_documents\example\example3.cpp(3) : error C2065: 'Student' : undeclared identifier
D:\my_c_documents\example\example3.cpp(3) : error C2065: 'z3' : undeclared identifier
D:\my_c_documents\example\example3.cpp(3) : error C2061: syntax error : identifier 'Student'
D:\my_c_documents\example\example3.cpp(4) : error C2227: left of '->set' must point to class/struct/union
D:\my_c_documents\example\example3.cpp(5) : error C2227: left of '->show' must point to class/struct/union
D:\my_c_documents\example\example3.cpp(6) : error C2541: delete : cannot delete objects that are not pointers
D:\my_c_documents\example\example3.cpp(7) : error C2065: 'getchar' : undeclared identifier
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : error C2143: syntax error : missing ';' before '}'
D:\my_c_documents\example\example3.cpp(9) : fatal error C1003: error count exceeds 100; stopping compilation
执行 cl.exe 时出错.

example2.exe - 1 error(s), 0 warning(s)

新手啊,不懂啊,

[ 本帖最后由 cuixing158 于 2014-9-9 11:15 编辑 ]
2014-09-09 11:13
cuixing158
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-9-8
得分:0 
回复 10 楼 fl8962
灰常感谢,你说的对,包含了其他cpp文件
2014-09-12 16:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-435848-1-1.html




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

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