To fully master the C ++ programming technology, you must understand the structure, statements, variables, functions, preprocessing commands, input and output of C ++, this article analyzes and introduces the C ++ code that most users encounter.
Speaking of Cint introduction and compilation, we started to try to tame it this time. Starting with a piece of code, we have such a piece of C ++ code:
- #include <iostream>
- using namespace std;
- int main(){
- for(int i=0; i<10; i++)
- cout << "Hello World " << i << endl;
- return 0;
- }
If you want to use Cint to explain how to execute it instead of your compiler), what we need to do is: Create a console project to put libcint. place the dll in a place that can be found in the executable file, place the PATH environment variable to the PATH or put it together with your Executable File) set the project append include PATH to [CINT] \ inc to put libcint. add lib to the project and write code:
- # Include<G _ ci. h>
- Const char *SzHello=
- "# Include <iostream>"
- "Using namespace std ;"
- "Int main ()"
- "{"
- "For (intI=0; I<10; I ++ )"
- "Cout<<\ "Hello World \"<< I << Endl;"
- "}";
- Int main (int argc, char * argv [])
- {
- G _ init_cint ("cint ");
- G _ load_text (szHello );
- G _ exec_text ("main ()");
- G _ scratch_all ();
- System ("pause"); // pause
- Return 0;
- }
Compile and run the program. After running the program, you may see the Cint report saying that the header file iostream cannot be found. The header file iostream is in [CINT] \ include, you just need to copy [CINT] \ include to your executable file path (I am talking about the entire include folder ). If the script C ++ code is located in the disk file, it is simpler to assume that the helloworld. cxx file is C ++ code, then:
- #include <G__ci.h>
-
- int main(int argc, char* argv[])
- {
- G__init_cint("cint helloworld.cxx");
- G__scratch_all();
-
- system("pause");
- return 0;
- }
- Introduction to C ++
- Summary Notes on learning and exploring C ++ library functions
- Basic Conception and method of C ++ Class Library Design
- Does C ++ really have market value?
- Basic Conception and method of C ++ Class Library Design