How to make C++ code interact with files

Hey all!I have just registered in this site and I am really excited!I have been reading upon C++ programming for some days and I have learned some basics, functions-objects-string literals-var types etc but if you don't mind,I have some questions I would like to ask.
-First,in header files am I only to state/initialize variables or can I include functions too?If so,can I import the header file in such a way to int main?
-Last,what's the code to open sound files,videos,images? Can I make the app interact with other apps too?For example,create a program so when I run it, it will open another app and do some things?
Could you suggest any tuts to learn how to make win32 window ( not console log ) apps?To make a game i.e like Space Cadet.
Much appreciated in advance and please bare with my noob skills :)
1. You can put functions, but if the header is included in multiple source files you should make the functions inline. If the header is only included in one file you can write anything you want.

Headers can also be abused:
Quote.h:
" ,
Text.h:
Hello, World!,
Main.cpp:
1
2
3
4
5
6
7
8
9
namespace lol
{
    #include <iostream>
}

int main()
{
    lol::std::cout << #include "Quote.h" #include "Text.h" #include "Quote.h" << lol::std::endl;
}
Essentially, #include just tells the preprocessor "Hey, copy and paste eveything in this file at this point in this source file! Thanks!" Thus, your header files are just plain text and could actually have any extension, *.h and *.hpp are just used for convention just as *.cc, *.cpp, and *.cxx are used for convention. You shouldn't abuse header files like this though.


2. http://www.cplusplus.com/doc/tutorial/files/
C++ does not have built in support for sound and image processing and communicating between programs. You need to find libraries and OS-specific functions for that.
Last edited on
Topic archived. No new replies allowed.