Importing C++ Programs in Python def run(a): =a+'.cpp' =a+'.exe' os.system('g++ ' + + ' -o ' + ) os.system( ) if ==' ': main(sys.argv[ :]) Output of the above program C:\Users\Dell>python c:\pyprg\main.py -i c:\pyprg\hello c:\pyprg\hello.cpp: In function 'int main()': c:\pyprg\hello.cpp: : error: expected ';' before 'return' std::cout<<"hello" ^ ; return ; ~~~~~~ 'c:\pyprg\hello.exe' is not recognized as an internal or external command, operable program or batch file. In the above program Python helps to display the error in C++. The error is displayed along with its line number. The line number starts from the beginning of the C++ program Note • C++ is a compiler based language while Python is an interpreter based language.
• C++is compiled statically whereas Python is interpreted dynamically • A static typed language like C++ requires the programmer to explicitly tell the computer what “data type” each data value is going to use. • A dynamic typed language like Python, doesn’t require the data type to be given explicitly for the data. Python manipulate the variable based on the type of value. • A scripting language is a programming language designed for integrating and communicating with other programming languages • MinGW refers to a set of runtime header files, used in compiling and linking the code of C, C++ and FORTRAN to be run on Windows Operating System Points to remember: 12th Computer Chapter - - • The dot (.) operator is used to access the functions of a imported module • sys module provides access to some variables used by the interpreter and to functions that interact with the interpreter • OS module in Python provides a way of using operating system dependent functionality • The getopt module of Python helps you to parse (split) command-line options and arguments Points to remember: Hands on Experience .
Write a C++ program to create a class called Student with the following details Protected member Rno integer Public members void Readno(int); to accept roll number and assign to Rno void Writeno(); To display Rno. The class Test is derived Publically from the Student class contains the