Skip to content
neuroai

neuroai

  • Home
  • All Courses
  • Log In
  • About
neuroai
neuroai

子函数放文件中

  1. C++程序设计
  2. 第十章 文件操作
  3. 子函数放文件中

一、主函数文件要include 头文件 fun.h

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


int main()
{   int a=6,b=4;
    cout<<fun(a,b);
    return 0;
}

二、头文件fun.h 写具体函数的声明

int fun(int,int);

三、源文件fun.cpp,写子函数定义

int  fun(int a, int b){
    return a+b;
}
Previous Topic
Back to Lesson
Next Lesson

About NeuroAI

NeuroAI 提供 C++、数据结构与算法、信息学真题、数学竞赛和 AP 微积分课程。

Courses

All Courses
C++ 程序设计
数据结构与算法
信息学奥赛真题

Account

Log In
Lost Password

© 2026 neuroai - WordPress Theme by Kadence WP

Facebook X Instagram
Scroll to top
  • Home
  • All Courses
  • Log In
  • About