注册 登录
编程论坛 C++教室

求助 一个最简单的程序 vc++ 6.0编译 

afraidhlq 发布于 2008-03-17 18:42, 1686 次点击
才开始学呢,大侠们帮帮我啊!
//student.h
#ifndef STUDENT_h
#define STUDEN_h
class Student
{
public:
    void input(char* n,char *na,float s);
    void modify(float s);
    void display();
private:
    float score;
    char* name;
    char* id;
};
#endif
//student.cpp
#include<iostream.h>
#include<string.h>
#include "Student.h"
void Student::input(char* n,char* na,float s)
{
    score=s;
    id=new char[strlen(n)+1];
    strcpy(id,n);
    name=new char[strlen(na)+1];
    strcpy(name,na);
}
void Student::modify (float s)
{
    score=s;
}
void Student::display ()
{
    cout << "\n id:" << id;
    cout << "\n name:" << name;
    cout << "\n score:" << score;
}
10 回复
#2
afraidhlq2008-03-17 18:42
--------------------Configuration: 2 - Win32 Debug--------------------
Compiling...
student.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/2.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

2.exe - 1 error(s), 0 warning(s)
#3
sunkaidong2008-03-17 18:52
提示没有函数入口
#4
afraidhlq2008-03-17 19:03
谢谢啊!
才开始学,还以以只要定义了类,有了类的实现就可以编译呢,忘记了连main函数都没写
。。。。。
#5
newyj2008-03-17 19:21
没有 构造函数
#6
sunkaidong2008-03-17 19:23
构造函数系统会自己有默认的..而且不像java那么麻烦
#7
iyth615252008-03-17 19:33
求助 哪个错了???
#include<stdio.h>
#include<string.h>
void main()
{
    for( ; ; )
    {    
        switch(menu_selsct())
    
        { case 1:
            printf("通讯录链表的建立\n");
            break;
          case 2:
            printf("通讯者结点的插入\n");
            break;
          case 3:
            printf("通讯者结点的查询\n");
            break;
          case 4:
            printf("通讯者结点的删除\n");
            break;
          case 5:
            printf("通讯录链表的输出\n");
            break;
          case 0:
            printf("再见!\n");
            break;
           return;
        }
    }
}
int menu_select()
{
    int sn;
    printf("通讯录管理系统\n");
    printf("****************\n");
    printf("1.通讯录链表的建立\n");
    printf("2.通讯者结点的插入\n");
    printf("3.通讯者结点的查询\n");
    printf("4.通讯者结点的删除\n");
    printf("5.通讯录链表的输出\n");
    printf("0.退出管理系统\n");
    printf("*****************\n");
    printf("请选择0—5:");
    for( ; ; )
    {  
        scanf("%d",&sn);
        if(sn<0!!sn>5)
            printf("\n\t输入有误,重选0—5:");
        else break;
    }
    return sn;
}
#8
tianying2008-03-17 20:25
什么问题啊?说个清楚,才能让别人帮助你
#9
iyth615252008-03-18 18:53
对不起大家啊,代码复制错误了,抱歉啊!!!
#include<stdio.h>
#include<string.h>
void main()
{
    for( ; ; )
    {    
        switch(menu_selsct())
    
        { case 1:
            printf("通讯录链表的建立\n");
            break;
          case 2:
            printf("通讯者结点的插入\n");
            break;
          case 3:
            printf("通讯者结点的查询\n");
            break;
          case 4:
            printf("通讯者结点的删除\n");
            break;
          case 5:
            printf("通讯录链表的输出\n");
            break;
          case 0:
            printf("再见!\n");
            break;
           return;
        }
    }
}
int menu_select()
{
   int  sn;
   printf("通讯录管理系统\n");
   printf("****************\n");
   printf("1.通讯录链表的建立\n");
   printf("2.通讯者结点的插入\n");
   printf("3.通讯者结点的查询\n");
   printf("4.通讯者结点的删除\n");
   printf("5.通讯录链表的输出\n");
   printf("0.退出管理系统\n");
   printf("*****************\n");
   for( ; ; )
   {    scanf("%d",&sn);
        if(sn<0!!sn>5)
            printf("输入错误,重选0-5\n");
        else
            break;
    }
    return sn;
}
#10
sunkaidong2008-03-18 18:56
menu_selsct()????   menu_select()
#11
afraidhlq2008-03-18 21:30
唉,这种错误我也犯过呢
1