I am currently programming a program which searches song according to diffrent parameters. In my system there are 2 types of songs: lyric and instrumetal. Since i need to p
As already answered, I would also use #pragma once, it is more convenient and clean. But be aware that it is not a C++ standard, so it can be a problem if you have to use different compilers (although it is a wide-spread extension).
You have to tell preprocessor to include your header files only once. You can achieve by adding #pragma once
on the top of all *.h
files:
#pragma once
//Your header file's code
It is also a good practice to always begin header files with this line.
They both include 'Song.h' file and preprocessor takes the file content twice. You need to write 'LyricsSong.h' and 'InstrumentalSong.h' file contents inside #ifndef #define and #endif directives. Like this
#ifndef LYRICS_SONG_H
#define LYRICS_SONG_H
your code goes here.
...
#endif