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

文件包含 包不包括 包含c++源文件

九天冥盟 发布于 2016-02-05 19:37, 2002 次点击
       为什么我包含了一个“**.cpp" 编译不通过啊?
因为只看文件,所以简写了;
lianbao-jianli.cpp:
#include "lianbiao-insert.cpp"
#include <iostream>
using namespace std;

Student *creat_1();
   
void print(Student *head);   
int main()
{
  Student *p;

    Student *head;

    head=creat_1();
    cout<<"intput :"<<"\t";
    cin>>p->number>>p->score;
    insert_1(head,p);

    print(head);
return 0;
}

struct Student *creat_1()
{
   ...................
}

void  print(Student *head)
{   .............}

lianbao-insert.cpp:

#include <iostream>
#include "l.h"

using namespace std;

Student *insert_1()
{....................}


2 回复
#2
hjx11202016-02-05 20:08
楼主你的程序入口函数都没有,不明白你要搞什么,另外,C++工程通常自定义头文件格式是这个样子的

#ifndef L.H
#define L.H
...
...
...
#endif

多看看书吧,少年,这些书里都有讲解,也是最基础的部分
#3
wengbin2016-02-06 11:55
不要包含.cpp,必要的话包含自己写的.h文件就好。
1