Introduction to C++ Programming Language in Eclipse IDE
Verified
Added on  2022/11/13
|7
|1300
|168
AI Summary
This article provides an introduction to C++ programming language in Eclipse IDE. It covers challenges faced during IDE setup, data types, string manipulation, pointers, and iostream library headers.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head:INTRODUCTION TO C++ PROGRAMMING LANGUAGE IN ECLIPSE IDE 1 Introduction to c++ programming language in Eclipse IDE Student Course Instructor Date
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
INTRODUCTION TO C++ PROGRAMMING LANGUAGE IN ECLIPSEIDE 2 Part I There are several challenges that Eclipse IDE developers encounter on their first use of the environment. During the IDE setup, the installation of the C and C++ development toolkit (CDT), which is Eclipse plug-ins that provide both C and C++ development was a challenge. The issue was as a result of a dependency conflict during its integration into the eclipse IDE. The conflict dependency error encountered was due to the existence of some packages that are packaged in CDT and already defined in Eclipse IDE. The second issue faced with Eclipse IDE was during project execution. The project was failing on launch due to lack as it could not find required execution binaries. The project setup was the issue and once all required parameters were configured, a project executed successfully. C++ has different data types, which are either user-defined data types and built-in data types.User-defined data types supported in C++ are unions, classes, enumerations, and structures. Both structures and unions are used to group similar data types into a single name. C+ + has been extended to include classes, union, and structures which serve as the basis of Object- Oriented programming (OOP). A Class in C++ defines both functions and data required in the object of some classes (Kishor, 2014). Enumerations are used as a named integer constant which can be used to specify the values which can be assigned to enumeration variables. Build-in data types which are available in C++ void, integral and floating-point. Both integral and floating- point can take various types of modifiers, which are used to determine the range, and sizes of the subjected data types. Integral data types can store integers, characters, float, and double. There are some notable differences between Java and C++ data types. In Java, objects are not treated as values, but in C++ they are values. On the same note, value semantics are used by default in C++ but java makes use of references semantic.Strings in C++ are error-prone and can be
INTRODUCTION TO C++ PROGRAMMING LANGUAGE IN ECLIPSEIDE 3 compromised by attackers which occurs due to memory allocation by programmers. In this regard, it is the responsibility of the programmers to consider safe memory allocation and deallocation if not in use. class assignment{ string name; int marks; public: void student() { cout << "Enter student name"<< endl; cin>>name; cout<<"Enter student marks"<<endl; cin>>marks; } void output() { cout << "student Name:"<<name<< endl; cout << "Student Marks:"<<marks<< endl; }}; int main() { assignment A; A.student(); A.output(); } References Kishor, N. R. (2014). International Journal of Advance Research in Computer Science and Management Studies.International Journal,2(3), pp. 243-246. Part II
INTRODUCTION TO C++ PROGRAMMING LANGUAGE IN ECLIPSEIDE 4 String manipulation in C++ is very common as users are tricked to process a given data that is passed as string and later content of the data is changed. Some of the string manipulation errors are; improper bounding of string copies which occurs when required data is copied from to the other in a fixed-length character array. The next string manipulation error in C++ is caused by both copying and concatenating strings (Seacord, 2016). Such errors are common and prone to happen because many of the C++ standard libraries that perform such operations make use of unbounded copy operations. The copy and concatenation error can be avoided by making use of strlen ( ) function to allocated required memory dynamically. The unbound copy can be avoided by calling limited extraction operation to a specific number of characters in cases where ios_base:: width has been set to greater than zero. It resolves the error because extraction call operation with is reset to zero which makes it secure. Failing to reset copy and concatenation function to zero value upon its use can be used to point out some security vulnerability in the C+ + program. By inputting more than one character in the below program results to out of bounds write operation. int main() { char huf[1]; cin >> huf; cout << "Print:" << huf << endl; } References Seacord, R., 2016. Secure coding in C and C++ of strings and integers.IEEE security & privacy,4(1),pp.74-76.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
INTRODUCTION TO C++ PROGRAMMING LANGUAGE IN ECLIPSEIDE 5 Part III In C++, pointers are known to be variables used to hold the required memory address. Pointers are robust in such a way that they can store either single or single variables or some addresses of array cells. Some programming benefits of using pointers are; it increases program execution speed, it also reduces both complexity and length of the code and makes it possible to access variables defined from outside of the function (Flater & Guthrie, 2013). Arrays are useful when using pointers because they can be used to point and pass the required variables. The difference between the address-of operator (&) and dereference operator (*) is that the address operator can make use of Ivalue such as & var and dereference operator (*) can take any pointer variable such as *ptr_var. int k[2]; int* ptr; ptr = &k[2]; References Flater, D., & Guthrie, W. F. (2013). A case study of performance degradation attributable to run- time boundschecks on C++ vector access.Journal of research of the National Instituteof Standards and Technology,(5)118, 260. Part IV
INTRODUCTION TO C++ PROGRAMMING LANGUAGE IN ECLIPSEIDE 6 In C++ programming, use of <iostream> library headers which are used to define required standard streams of objects either input/output may pose some vulnerabilities during execution. Using iostream header in the program may result in an automatic call of the other related headers like <ostream> and <istream> (Beard, Li & Chamberlain, 2017). Some headers are used for reading data types such as strings that are prone to manipulation. Vulnerability identification can be done by identifying some headers that may cause security threats when called in any program. #include <iostream> #include <math.h> using namespace std; int main(){ int p; cout<<"Enter value p"<<endl; cin>>p; cout<<"The square root is:"<<sqrt(p)<<endl; } References Beard, J. C., Li, P., & Chamberlain, R. D. (2017). RaftLib: a C++ template library for high performancestreamparallelprocessing.TheInternationalJournalofHigh PerformanceComputing Applications,31(5), 391-404.
INTRODUCTION TO C++ PROGRAMMING LANGUAGE IN ECLIPSEIDE 7