Creating function libraries

Hello!

I have some program with identical functions. I want to do one file with general functions and some programs using general functions. How to do it? I tried make general file as .C and run “root general.C program.C” and make general file as .h and include it in program “#include general.h”, but it doesn’t work. I attach a header file and one of the programs.

Pi0 (1).C (5.3 KB) fun (1).h (1.4 KB)


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22
Platform: Ubuntu
Compiler: Not Provided


general.h

void a() {
   cout << "Hello fom a()" << endl;
}

b.C

#include "general.h"
void b()
{
   cout << "Hello from b\n" << endl;
   a();
}

execution:

root [0] .x b.C
Hello from b

Hello fom a()
root [1] 

What’s the difference? general.h and b.C are the same thing.

Sorry, wrong copy/paste. I fixed the previous post.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.