L1_-_Basic_of_C++_(1_on_1)

L1_-_Basic_of_C++_(1_on_1) - Lecture 1 From C to C+ Lecture...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 1 From C to C++
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 --- 56 [CS1102C AY0809S2 Lecture 1] Lecture Overview ± Introduction to C++ ± Basic Compilation ± ² Control Statements ² Declarations ² Functions ² Useful Library in C
Background image of page 2
3 --- 56 [CS1102C AY0809S2 Lecture 1] What is C++? ± Developed by Bjarne Stroustrup ² First commercial release in 1985 ² Originally known as “C with Classes” ² Renamed to “C++” in 1983 ± Main features: ² General purpose ² Object Oriented ² Compatibility with C ± More on this later…
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 --- 56 [CS1102C AY0809S2 Lecture 1] The Good and Bad News ± Good News: ² Only minor incompatibility with C ± Most programs introduced in CS1101C is valid and compilable ² Proficiency in C++ is a great advantage: ± Much sought after in the industry ± Picking up other OO languages like Java, C# is relatively easy ± Bad News: ² It is a HUGE and COMPLEX language ² Compatibility with C detracts from pure Object Oriented approach
Background image of page 4
5 --- 56 [CS1102C AY0809S2 Lecture 1] Advice ± Unlike CS1101C, we are not concentrating on the programming language itself ² C++ coverage is done by lecture 3! ² Assume reasonable grasp afterwards ± CS1102C is more conceptual based and “higher level” ² Ideas that are true regardless of the actual implementation language ± However, more than 30% of your CA comes from actual hands-on: ² Labs: 20%, PE: 15% ² Programming based questions in midterm and finals ± Conclusion: ² Try hard to be familiar with C++ in the first few weeks
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic Compilation Program Compilation Under Sunfire
Background image of page 6
7 --- 56 [CS1102C AY0809S2 Lecture 1] Sunfire : How to compile? ± Log in to your sunfire account using SSH client ± Note: C++ program has the extension “.cpp” ± Example: helloWorld.cpp ± Steps for program compilation: 1. Edit program using your favorite editor ( vim , pico etc) 2. Compile using the command: g++ -Wall fileName.cpp OR g++ -Wall –o executable_name fileName.cpp 3. [ Compilation Error ]: Go to step 1 4. Execute the program: a.out OR executable_name
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Simple C++ Program Getting Started
Background image of page 8
9 --- 56 [CS1102C AY0809S2 Lecture 1] Input and Output ± Output using cout ± Input using cin ± To use either cin or cout , add the following two lines to the start of program #include <iostream> using namespace std; ± Do not be alarmed of the above ² Full explanation will be given later ² At this point, just “cut and paste” into every C++ program
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 --- 56 [CS1102C AY0809S2 Lecture 1] “Hello World!” in C and C++ #include <iostream> using namespace std; int main () { cout << “Hello World!” << endl; return 0; } #include <stdio.h> int main () { printf (“Hello World!\n"); return 0; } C version C++ version ± Side by side comparison ± Note that “ \n ” is represented by endl in C++: ² \n ” is also valid in C++
Background image of page 10
11 --- 56 [CS1102C AY0809S2 Lecture 1] Another simple C++ program #include <iostream> using namespace std; const double PI = 3.14159; int main () { int radius; cout << "Enter a radius " ;
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 56

L1_-_Basic_of_C++_(1_on_1) - Lecture 1 From C to C+ Lecture...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online