does anyone know of any tutorials etc for creating and using your own header files?
does anyone know of any tutorials etc for creating and using your own header files?
Make New Unit (in dev) and write whatever you want in it .. Then rename it into hello.h and in your application put #include "hello.h" (It has to be added to the project first)
what does signature stand for?
yes i know that. but how would i call to it. or would it be like if i had a header file i made including tons of variables, it would be like the varibales were writtin into my main .cpp document?
If you've got a function in your header file call it this way:
function() .. just like all other ones
what does signature stand for?
The only difference is that you dont make #include <file.h> put with quotes (") like #include "file.h"
what does signature stand for?
Yep, thats pretty much how it goes. When you start including that same header in multiple files though, if you want them to use the see same variables you will need to use the extern keyword. If you want a simple example of a single header suited for a single cpp here goes..any questions on part of it, just ask.Originally posted by Klinerr1
yes i know that. but how would i call to it. or would it be like if i had a header file i made including tons of variables, it would be like the varibales were writtin into my main .cpp document?
Code:#ifndef VECTOR_H #define VECTOR_H typedef struct _tagVector { float x; float y; float z; }Vector3; #endif /* VECTOR_H */
uhh that is not a library file, that is a header file.
In visual C++ in the new project menu, you choose Static Linked Library and write your code, hit the build button and voila you have a library.
"There are three kinds of people in the world...
Those that can count and those that can't."
wut im trying to do is put my intro for a game in a seperatefile. because its like 500 lines down. i want the intro to play before the game so would i pretend intro.h or wutever is a function and call it as if the function was named intro.h
Call it like all other functions but #include "intro.h" in main.cpp
what does signature stand for?
why not put it in another .cpp file, and add it to your project, and prototype it in main.cpp (or whatever your main file is called)
"There are three kinds of people in the world...
Those that can count and those that can't."
oh stupid me
You're just starting
what does signature stand for?
so is this right (im not usign my intro ni the header)
menuscreen_.cpp looks like thisPHP Code:
#include <iostream>
#include <string>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <fstream>
#include "menuscreen_.cpp"
using namespace std;
int menuscreen_.cpp();
char * menuscreenv;
int gold, health, magic, attack, aim, defence, ynvari, charactertype;
string empty, weapon, shield, armor, szWord, szLine, player, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18, item19, item20, item21, item22, item23, item24, item25, item26, item27, item28, item29, item30;
bool menuselect;
int main(int argc, char *argv[])
{
int menuscreen_.cpp();
cin.get();
return 0;
}
do i have to do anything if i want to use the same variables in both files? and have it so both variables hold the same data?PHP Code:
#include <iostream>
#include <string>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <fstream>
int main(int argc, char *argv[])
{
cout << menuscreenv << endl;
cin >> menuselect;
if (menuscreen == 1){
}
else if (menuscreen == 2){
ofstream fout;
fout.open("stats.sav");
fout << "Player: " << player << " ";
fout << "CharacterType: " << charactertype << " ";
fout << "Health: " << health << " ";
fout << "Gold: " << gold << " ";
fout << "Magic: " << magic << " ";
fout << "Attack: " << attack << " ";
fout << "Aim: " << aim << " ";
fout << "Defence: "<< defence << " ";
fout << "Weapon: " << weapon << " ";
fout << "Shield: " << shield << " ";
fout << "Armor: " << armor << " ";
fout << "Item1: " << item1 << " ";
fout << "Item2: " << item2 << " ";
fout << "Item3: " << item3 << " ";
fout << "Item4: " << item4 << " ";
fout << "Item5: " << item5 << " ";
fout << "Item6: " << item6 << " ";
fout << "Item7: " << item7 << " ";
fout << "Item8: " << item8 << " ";
fout << "Item9: " << item9 << " ";
fout << "Item10: " << item10 << " ";
fout << "Item11: " << item11 << " ";
fout << "Item12: " << item12 << " ";
fout << "Item13: " << item13 << " ";
fout << "Item14: " << item14 << " ";
fout << "Item15: " << item15 << " ";
fout << "Item16: " << item16 << " ";
fout << "Item17: " << item17 << " ";
fout << "Item18: " << item18 << " ";
fout << "Item19: " << item19 << " ";
fout << "Item20: " << item20 << " ";
fout << "Item21: " << item21 << " ";
fout << "Item22: " << item22 << " ";
fout << "Item23: " << item23 << " ";
fout << "Item24: " << item24 << " ";
fout << "Item25: " << item25 << " ";
fout << "Item26: " << item26 << " ";
fout << "Item27: " << item27 << " ";
fout << "Item28: " << item28 << " ";
fout << "Item29: " << item29 << " ";
fout << "Item30: " << item30 << " ";
fout.close();
}
else if (menuscreen == 3){
}
else if (menuscreen == 4){
}
else if (menuscreen == 5){
}
}
no, you don't have to include .cpp files. I don't even think that would compile. Just add the other .cpp file to your project, and any variables you need from it, put an extern at the top of the main source file for them. And any functions, just prototype them like you regularly would.
extern?and i need it so the cpp fies read variables from the main.cpp file.