for Robot Artificial Inteligence

11. start Project in codeblock

|

Project start

  • Create Project folder
  • and it will be two folder : sources, Headers.
  • and create main.cpp

main.cpp

#include <iostream>
#include "ourfirstlibrary.h"
using namespace std;
/* preprocessor directives and multi-file project */

#define PI 3.14

int main()
{
    showHelp();
    cout << a << endl;
    return 0;
}

```c

- and create outfirstlibrary.h
> outfirstlibrary.h

#ifndef OURFIRSTLIBRARY_H_INCLUDED #define OURFIRSTLIBRARY_H_INCLUDED

extern int a; //external (oustide) it means that here we do not reserve MEMORY for variable a /** this is going to help you **/ void showHelp();

#endif // OURFIRSTLIBRARY_H_INCLUDED


- and create outfirstlibrary.cpp
> outfirstlibrary.cpp


```c
#include <iostream>
#include "ourfirstlibrary.h"
using namespace std;

int a = 50;
void showHelp()
{
    cout << "this is help" << endl;
}
  • Head file은 cpp 파일들을 연결시켜주는 역할을 한다. (python 으로 치면 import를 하기 위해 만들어저있는 파일들)
  • head file이 이용되는 이유는 각 파일마다 분류가 나누어 져있는데 나중에 Main 클래스에다가 Import하기 위함이다.

Comments