Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://pastebin.com/u/TheWhiteFang
- //this code contains 3 parts (mainstr.cpp,str.cpp,str.h)
- -----------------------------------------------------------------------------------------------------------------------------------
- //str.cpp
- //declare string
- #include <string>
- using namespace std;
- string name = "AFK";
- -----------------------------------------------------------------------------------------------------------------------------------
- //str.h
- #ifndef STR_H // header guards
- #define STR_H
- #include <string>
- using namespace std;
- // extern tells the compiler this variable is declared elsewhere
- extern string name;
- #endif;
- -----------------------------------------------------------------------------------------------------------------------------------
- //mainstr.cpp
- #include "str.h"
- #include <iostream>
- int main()
- {
- cout << name <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement