personal library of functions...

I have a project that includes several windows, each has a table. I have functions that each of these tables can use. I need to know what's the usual way to have my own library of functions for this project included so that all windows can use the functions.

Thanks!
Usually the tables would be built into a class that can be manipulated.

Barring that, you'd have a separate .c or .cpp file with functions that manipulate tables in it, and an appropriate .h (header) file.

A quickie example:
1
2
3
4
5
6
7
// hello.h
#ifndef HELLO_H
#define HELLO_H

void hello();

#endif 


1
2
3
4
5
6
7
8
// hello.cpp

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

void hello() {
  std::cout << "Hello world!" << std::endl;
  }


1
2
3
4
5
6
7
// main.cpp
#include "hello.h"

int main() {
  hello();
  return 0;
  }


Compile with:
g++ -o greetings main.cpp hello.cpp

and execute the usual way:
./greetings

Hope this helps.
Last edited on
Topic archived. No new replies allowed.