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

有关 文件包含的问题?

九天冥盟 发布于 2016-02-05 15:21, 2078 次点击
为什么我文件“l.h"包含在 ”insert.cpp"里,可以编译通过,但是组建不行
  系统给我的提示是:unresolved external symbol _main
                      未解决的外部符号_main

  还有一点;文件“insert.cpp"我还打算放在另一个文件中;
insert.cpp:

#include <iostream>
#include "l.h"
using namespace std;

Student *insert_1(Student *head,Student *p3)
{
    Student *p1,*p2;
    p2=p1=head;
    if(head==NULL)
    {
     head=p3;p3->next=NULL;
    }
    else
    {
        while(p3!=NULL&&p3->number>p1->number)
        {
            p2=p1;p1=p1->next;}
        
        if(p3==NULL)
        {
            p2->next=p3;p3->next=NULL;}
        else
        {
            if(head==p1)
            {
                head=p3;p3->next=p1;}
            else
            {
                p2->next=p3;p3->next=p1;}
        }
    }
    return head;
}
l.h:
struct  Student
{
    long int number;
    float  score;
    struct Student *next;
};

3 回复
#2
九天冥盟2016-02-06 15:44
#3
yangfrancis2016-02-06 16:59
要求主函数?
#4
alice_usnet2016-03-08 22:38
一个可运行的程序必须要有主函数,主函数是程序的入口点。如果你不需要主函数的话可以做一个链接库文件,供其他程序调用。
1