C++

RESULT
















QUESTION & DISCUSSION
1.       How to
a.        Compilation process.
Compiling a source code file in C++ is a four-step process. For example, if you have a C++ source code file named prog1.cpp and you execute the compile command
g++ -Wall -ansi -o prog1 prog1.cpp
the compilation process looks like this:
1.       The C++ preprocessor copies the contents of the included header files into the source code file, generates macro code, and replaces symbolic constants defined using #define with their values.
2.       The expanded source code file produced by the C++ preprocessor is compiled into the assembly language for the platform.
3.       The assembler code generated by the compiler is assembled into the object code for the platform.
4.       The object code file generated by the assembler is linked together with the object code files for any library functions used to produce an executable file.
By using appropriate compiler options, we can stop this process at any stage.
1.       To stop the process after the preprocessor step, you can use the -E option:
2.          g++ -E prog1.cpp
The expanded source code file will be printed on standard output (the screen by default); you can redirect the output to a file if you wish. Note that the expanded source code file is often incredibly large - a 20 line source code file can easily produce an expanded file of 20,000 lines or more, depending on which header files were included.
3.       To stop the process after the compile step, you can use the -S option:
4.          g++ -Wall -ansi -S prog1.cpp
By default, the assembler code for a source file named filename.cpp will be placed in a file named filename.s.
5.       To stop the process after the assembly step, you can use the -c option:
6.          g++ -Wall -ansi -c prog1.cpp
By default, the assembler code for a source file named filename.cpp will be placed in a file named filename.o.


                             b. Execute the program
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
LPCTSTR lpApplicationName = "C:/Windows/System32/cmd.exe"; /* The program to be executed */

LPSTARTUPINFO lpStartupInfo;
LPPROCESS_INFORMATION lpProcessInfo;

memset(&lpStartupInfo, 0, sizeof(lpStartupInfo));
memset(&lpProcessInfo, 0, sizeof(lpProcessInfo));

CreateProcess(lpApplicationName,

/* Create the process */
if (!CreateProcess(lpApplicationName
                   NULL, NULL, NULL,
                   NULL, NULL, NULL, NULL,
                   lpStartupInfo,
                   lpProcessInformation
                  )
   ) {
    std::cerr <<"Uh-Oh! CreateProcess() failed to start program \""<< lpApplicationName <<"\"\n";
    exit(1);
}

std::cout <<"Started program \""<< lpApplicationName <<"\" successfully\n";
2.       What is C++ Programming
C++ (pronounced see plus plus) is a general purpose programming language that is free-form and compiled. It is regarded as an intermediate-level language, as it comprises both high-level and low-level language features. It provides imperative, object-oriented and generic programming features.
C++ is one of the most popular programming languagesand is implemented on a wide variety of hardware and operating system platforms. As an efficient performance driven programming language it is used in systems software, application software, device drivers, embedded software, high-performance server and client applications, and entertainment software such as video games.Various entities provide both open source and proprietary C++ compiler software, including the FSF, LLVM, Microsoft and Intel.
It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs, C++ was originally named C with Classes, adding object-oriented features, such as classes, and other enhancements to the C programming language. The language was renamed C++ in 1983 as a pun involving the increment operator. It began as enhancements to C, first adding classes, then virtual functions, operator overloading, multiple inheritance, templates and exception handling, alongside changes to the type system and other features.
C++ is standardised by the International Organization for Standardization (ISO), which the latest (and current) having being ratified and published by ISO in September 2011 as ISO/IEC 14882:2011 (informally known as C++11).The C++ programming language was initially standardised in 1998 as ISO/IEC 14882:1998, which was amended by the 2003 technical corrigendum, ISO/IEC 14882:2003. The current standard (C++11) supersedes these, with new features and an enlarged standard library.

CONCLUSION
Learn how to creating a simple Programming and Run Program.

No comments:

Post a Comment