Location and hours. Game Programming in C++ About this course. This course is about. About this course. About this course
|
|
- Cameron Cross
- 7 years ago
- Views:
Transcription
1 Location and hours Game Programming in C++ Arjan Egges Lecture #1: Introduction, C++ basics Lectures Arjan Egges ( Room: BBL 065 Every Monday 1pm-3pm and Thursday 9am-11am Practical assignments Ben van Basten ( Rooms BBL-017, BBL-103, BBL-106, BBL115 Every Monday 3pm-5pm and Thursday 11am-1pm Please regularly consult website for updates: This course is about Cool Graphics Real-time Rendering, Shading Character Animation Artificial Intelligence Real-time Physics Designing Games and Levels About this course Introduction to the C++ programming language C++ has some distinct differences from Java/C# C++ is widely used in the industry Programming techniques for game development Games are very difficult applications to build Many different complex interactions with the program are required Uses many different hardware components Uses many resources (audio, visual, other data) About this course Game engines Concepts used, architecture How to properly use a game engine There are many C++ books, and many Game Programming books, but only a few books that properly handle both Book we use in this course: C++ for Game Programmers: Second Edition by Michael J. Dickheiser. Charles River Media, ISBN About this course Other interesting links: - Games and Game Programming website - Java to C++ tutorial Game/graphics engines: OGRE Delta3D Irrlicht And more 1
2 Practical assignments In the lectures, we will discuss programming techniques in C++ and game engine architecture There are several practical assignments that address topics discussed in the lecture Visual C++ tutorial during the first assignment In total 5 practical assignments Assignments will be done in teams of 2 Assignments 2-5 need to be approved to finish the course Practical assignments First three assignments: focused on using different C++ features. Last two assignments will be done with OGRE3D OGRE3D is a well-known graphics engine based on DirectX/OpenGL Not really a game engine, but a graphics engine Lecture schedule First four lectures will be overview of C++ C++ basics (variables, classes, functions ) Memory management (pointers, creating and deleting objects) Object-oriented programming in C++ The remainder of the lectures will address various chapters in the book Next to the material discussed in the book we will also look into existing game engine architectures (OGRE, Delta3D, Unreal, ) Hands-on programming exercises C++ versus other languages C++ vs. Java Java is interpreted Java is 100% object oriented (no global variables, etc.) C++ has separate class declaration and definition Strings are handled better in Java All non-primitive objects in Java are created using new Java class has no destructors C++ versus other languages C++ vs. C# C# doesn t allow for multiple inheritance, C++ does C# is higher level (less control over memory management, object lifetime, and so on) C# doesn t support templates C# has the extensive.net framework with lots of useful components, such as GUI, cryptography, networking, etc. In C# everything derives from a generic Object class (like in Java) Which language to use? So why not Game Programming in Java or Game Programming in C#? C++ is still an industry standard Many games are programmed in C++ or use (older) libraries written in C++ In games, object lifetime management is sometimes still necessary Understanding these concepts is very useful 2
3 Which language to use? Mostly, game companies use C++ for building their games C++ allows for both high- and low-level coding A lot of libraries and code is available Precise control over object lifetime, memory management, etc. Java is rarely used for games, but a lot of development is going on for Java3D, jmonkey engine, Java Scene Graphs, etc. C# is used in combination with XNA to produce Xbox games C# also neatly integrates with existing C++ libraries More game companies start to use C# for their games In Java: public class HelloWorld { /* Declare the main function. */ public static void main(string args[]) { System.out.println("Hello world!"); In C: // the printf function is located here #include <stdio.h> int main(int argc, char* argv[]) { printf("hello world!\n"); return 0; A few differences: C has global functions and no classes The printf function is loaded from a library In Java, the main takes one parameter as opposed to 2 in C In Java, the main does not return an exit code In C++: // cout is located here A simpler version also works: // cout is located here int main(int argc, char* argv[]) { cout << "Hello world!" << endl; return 0; void main() { cout << "Hello world!" << endl; 3
4 Hello, world The #include statement loads the iostream library used for printing and reading data from the keyboard Similar to packages in Java, C++ uses namespaces The using namespace std simply means that we will use functions/objects from the namespace std. Types in C++ Like Java/C#, C++ has primitive types like int, float, double C++ has no String class Use array of char or STL string (next lecture) No built in null keyword, but C++ uses 0 In many libraries, NULL is defined as macro for 0 to increase readability Definition: Usage: Enumerated types enum AvatarType { Wizard, Soldier, Spy, Blacksmith ; AvatarType myavatar = Soldier; AvatarType youravatar = Wizard; int r = fighttothedeath(myavatar, youravatar); Expressions Numeric expressions can cause many bugs if not taken care Implicit casting in C++ does not generate compiler error like in Java: int x = 5; int y = 2; double z = 5.0; double a = x / y; // a equals 2 double b = z / y; // b equals 2.5 double c = double(x)/double(y); // c equals 2.5 Expressions Booleans C++ knows a primitive bool type Creating and using boolean variables: bool x = true; bool y = false; 0 = false Non-zero (but normally 1) = true Standard logical operators are available (<=,!=, &&, ) Expressions!x Returns false if x is true and vice-versa. x < y Returns true if x is less than y. x > y Returns true if x is greater than y. x <= y Returns true if x is less than or equal to y. x >= y Returns true if x is greater than or equal to y. x == y Returns true if x and y are equal. x!= y Returns true if x and y are not equal. x && y Returns true only if both x and y are true. x ^^ y Returns true if either x or y is true (not both). x y Returns true if one of x or y is true (or both). 4
5 Expressions Always use parentheses in complex boolean expressions Easy to forget precedence rules Easier to read/understand for others Please note the difference between = and == Wrong use in Java creates a compile-time error, but not in C++! If-statement: For-loop: Conditional/Iteration if (c!= 'y' && c!= 'n') { cout << "Please choose yes or no: " << endl; cin >> c; // Input from user else for (int i = 0; i < 10; i++) cout << "The next number is:" << i << endl; Conditional statement Switch statement Example: switch (option) { case 'a': cout << "You chose option A" << endl; break; case 'b': cout << "You chose option B" << endl; break; default: cout << "Invalid option!" << endl; Conditional statement Combining cases: switch (option) { case 'a': case 'b': case 'c': cout << "Normal menu option" << endl; break; case '?': cout << "Help option" << endl; break; default: cout << "Invalid option!" << endl; An example application Write a C++ program that outputs the following pattern of asterisks: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * An example application void main() { cout << "*" << endl; cout << "* *" << endl; cout << "* * *" << endl; cout << "* * * *" << endl; cout << "* * * * *" << endl; cout << "* * * * * *" << endl; cout << "* * * * * * *" << endl; cout << "* * * * * * * *" << endl; 5
6 An example application void main() { cout << "Please enter the tree size: "; int treesize; cin >> treesize; cout << endl; for (int i=1; i<treesize; i++) { for (int j=0; j<i; j++) cout << "* "; cout << endl; While loop: Do-while loop: Iteration int a = 20; while ((a * 2) < 100) { a += 5; cout << a << endl; int a = 20; do a += 10; while ((a / 10) <= 4); An example application // Countdown program void main () { int n; cout << Enter the starting number: ; cin >> n; while (n > 0) { cout << n << ", "; n--; cout << "FIRE!" << endl; Input/Output Using the C++ iostream library Necessary include: Printing output on the screen: cout << "Hello, world!" << endl; cout << "The nr of points: " << points << endl; Receiving input from keyboard: int a = 0; cout << "Please enter a number: "; cin >> a; Input/Output This version guarantees no namespace conflict: Cout usage with namespace: std::cout << "Hello, world" << std::endl; Similar for cin and other objects/functions in the namespace // Writing a text file #include <fstream> File IO void main () { ofstream myfile("example.txt"); if (myfile.is_open()) { myfile << "This is a line." << endl; myfile << "And another line." << endl; myfile.close(); else cout << "Unable to open file"; 6
7 // Reading a text file #include <fstream> #include <string> void main() { string line; ifstream myfile("example.txt"); if (myfile.is_open()) { while (!myfile.eof() ) { getline(myfile,line); cout << line << endl; myfile.close(); else cout << "Unable to open file"; Variable types in C/C++ Normal variable: int a; Reference: double w = 3.4; double& b = w; Pointers (more about that later) Scope Variables are only accessible in the block in which they were defined if (x == 12) { double z = 48.7; cout << z << endl; for (int i = 0; i < 10; i++) { cout << i << endl; cout << i << endl; Functions Structure programs in a modular way Syntax: type name ( parameter1, parameter2,...) { statement Type: data type specifier Name: function identifier Parameters: each consists of data type specifier + parameter name Statement: the function body Functions int addition(int a, int b) { int r; r = a + b; return r; int main() { int z; z = addition(5,3); cout << "The result is " << z << endl; return 0; Functions A function with no parameters and no return type: void printmessage(void) { cout << "I'm a function!" << endl; Or: void printmessage() { cout << "I'm a function!" << endl; 7
8 Functions Functions Passing arguments by reference: void duplicate(int& a, int& b, int& c) { a*=2; b*=2; c*=2; int main() { int x=1; int y=3; int z=7; duplicate(x, y, z); cout << "x=" << x << ", y=" << y; cout << ", z=" << z << endl; return 0; void odd(int a); void even(int a); Declaring functions void main () { int i; do { cout << "Type a number (0 to exit): "; cin >> i; odd(i); while (i!=0); Declaring functions void odd(int a) { if ((a%2)!= 0) cout << "Number is odd." << endl; else even(a); void even(int a) { if ((a%2) == 0) cout << "Number is even." << endl; else odd(a); Building an executable Multiple steps: Preprocessor Evaluate macros and includes Compiler Create object files (.obj) from C++ code Linker Resolve the links between different parts of code, for example include libraries, MFC, etc. Create executable #include statements Preprocessor // standard IO library #include <cmath> // math functions #include "myownheader.h" // own header file < > look in standard directories look in working directory as well as standard directory Try to include as few headers as possible 8
9 Preprocessor #define statement Tells the preprocessor to do a text replace in the code #define PI 3.14 Can be useful for generic constants used everywhere in your program A macro can be undefined using the #undef statement Preprocessor You can use the preprocessor to conditionally compile code: #define CUSTOMXML #ifdef CUSTOMXML #include <mycustomxmlparser/saxparser.h> #include <mycustomxmlparser/saxhandle.h> #endif #ifndef CUSTOMXML #include <xmlparser2.1/saxparser.h> #include <xmlparser2.1/saxhandle.h> #endif Summary Basic overview of C++ syntax and usage Constructs Functions Expressions How to compile a C++ application Next lecture: Pointers and memory management Arrays 9
C++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
More informationBasics of I/O Streams and File I/O
Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading
More informationAn Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
More informationStorage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
More informationThe C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
More informationComp151. Definitions & Declarations
Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const
More informationName: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More informationBoolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
More informationBasic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C
Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
More informationPhys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions
Phys4051: C Lecture 2 & 3 Functions (Review) Comment Statements Variables & Operators Branching Instructions Comment Statements! Method 1: /* */! Method 2: // /* Single Line */ //Single Line /* This comment
More informationFirst Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
More informationJAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
More informationWhat is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...
What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control
More informationCORBA Programming with TAOX11. The C++11 CORBA Implementation
CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy
More informationMember Functions of the istream Class
Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,
More informationPART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
More informationMS Visual C++ Introduction. Quick Introduction. A1 Visual C++
MS Visual C++ Introduction 1 Quick Introduction The following pages provide a quick tutorial on using Microsoft Visual C++ 6.0 to produce a small project. There should be no major differences if you are
More informationIntroduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
More informationVisual Studio 2008 Express Editions
Visual Studio 2008 Express Editions Visual Studio 2008 Installation Instructions Burning a Visual Studio 2008 Express Editions DVD Download (http://www.microsoft.com/express/download/) the Visual Studio
More informationC++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
More informationC++ Outline. cout << "Enter two integers: "; int x, y; cin >> x >> y; cout << "The sum is: " << x + y << \n ;
C++ Outline Notes taken from: - Drake, Caleb. EECS 370 Course Notes, University of Illinois Chicago, Spring 97. Chapters 9, 10, 11, 13.1 & 13.2 - Horstman, Cay S. Mastering Object-Oriented Design in C++.
More informationKeywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
More informationAppendix K Introduction to Microsoft Visual C++ 6.0
Appendix K Introduction to Microsoft Visual C++ 6.0 This appendix serves as a quick reference for performing the following operations using the Microsoft Visual C++ integrated development environment (IDE):
More informationLecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
More informationHow To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)
TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions
More informationObject-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
More informationJava Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
More informationHandout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
More informationObject Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
More informationIS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
More informationKITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
More informationSequential Program Execution
Sequential Program Execution Quick Start Compile step once always g++ -o Realtor1 Realtor1.cpp mkdir labs cd labs Execute step mkdir 1 Realtor1 cd 1 cp../0/realtor.cpp Realtor1.cpp Submit step cp /samples/csc/155/labs/1/*.
More informationChapter 13 - The Preprocessor
Chapter 13 - The Preprocessor Outline 13.1 Introduction 13.2 The#include Preprocessor Directive 13.3 The#define Preprocessor Directive: Symbolic Constants 13.4 The#define Preprocessor Directive: Macros
More informationFundamentals of Programming
Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language
More informationMULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
More informationComputer Programming C++ Classes and Objects 15 th Lecture
Computer Programming C++ Classes and Objects 15 th Lecture 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University Copyrights 2013 Eom, Hyeonsang All Rights Reserved Outline
More informationStatements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
More informationEmbedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
More informationEmbedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
More informationChapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
More informationCh 7-1. Object-Oriented Programming and Classes
2014-1 Ch 7-1. Object-Oriented Programming and Classes May 10, 2014 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-2497;
More informationMultichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is
Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is preceded by an equal sign d. its name has undereline 2. Associations
More informationAP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
More information6. Control Structures
- 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,
More informationTranslating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language
Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description
More informationKonzepte objektorientierter Programmierung
Konzepte objektorientierter Programmierung Prof. Dr. Peter Müller Werner Dietl Software Component Technology Exercises 3: Some More OO Languages Wintersemester 04/05 Agenda for Today 2 Homework Finish
More informationJ a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
More informationCommon Beginner C++ Programming Mistakes
Common Beginner C++ Programming Mistakes This documents some common C++ mistakes that beginning programmers make. These errors are two types: Syntax errors these are detected at compile time and you won't
More informationIntroduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
More informationCpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing
CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects
More informationPassing 1D arrays to functions.
Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,
More informationMoving from C++ to VBA
Introduction College of Engineering and Computer Science Mechanical Engineering Department Mechanical Engineering 309 Numerical Analysis of Engineering Systems Fall 2014 Number: 15237 Instructor: Larry
More informationpublic static void main(string[] args) { System.out.println("hello, world"); } }
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
More informationCrash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
More informationChapter 9 Text Files User Defined Data Types User Defined Header Files
Chapter 9 Text Files User Defined Data Types User Defined Header Files 9-1 Using Text Files in Your C++ Programs 1. A text file is a file containing data you wish to use in your program. A text file does
More informationC++ Language Tutorial
cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain
More information9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
More informationEl Dorado Union High School District Educational Services
El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.
More informationC++ Input/Output: Streams
C++ Input/Output: Streams 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: istream
More informationOperator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example
Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics
More information6.S096 Lecture 1 Introduction to C
6.S096 Lecture 1 Introduction to C Welcome to the Memory Jungle Andre Kessler Andre Kessler 6.S096 Lecture 1 Introduction to C 1 / 30 Outline 1 Motivation 2 Class Logistics 3 Memory Model 4 Compiling 5
More informationUEE1302 (1102) F10 Introduction to Computers and Programming
Computational Intelligence on Automation Lab @ NCTU UEE1302 (1102) F10 Introduction to Computers and Programming Programming Lecture 03 Flow of Control (Part II): Repetition while,for & do..while Learning
More informationC++ Programming Language
C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract
More informationLecture 5: Java Fundamentals III
Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd
More informationJava (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
More informationCopyright 2001, Bill Trudell. Permission is granted to copy for the PLoP 2001 conference. All other rights reserved.
The Secret Partner Pattern Revision 3a by Bill Trudell, July 23, 2001 Submitted to the Pattern Languages of Programs Shepherd: Neil Harrison PC Member: Kyle Brown Thumbnail This paper describes the Secret
More informationCS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
More informationClass 16: Function Parameters and Polymorphism
Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15
More informationC++ Overloading, Constructors, Assignment operator
C++ Overloading, Constructors, Assignment operator 1 Overloading Before looking at the initialization of objects in C++ with constructors, we need to understand what function overloading is In C, two functions
More informationChapter 1 Java Program Design and Development
presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented
More informationTutorial on C Language Programming
Tutorial on C Language Programming Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:
More informationCS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java
CS1020 Data Structures and Algorithms I Lecture Note #1 Introduction to Java Objectives Java Basic Java features C Java Translate C programs in CS1010 into Java programs 2 References Chapter 1 Section
More informationThis copy of the text was produced at 20:37 on 4/10/2014.
Programming in C++ This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License To view a copy of this license, visit http://creativecommonsorg/licenses/by-nc-sa/30/ or
More informationThe programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
More informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper
More information6.s096. Introduction to C and C++
6.s096 Introduction to C and C++ 1 Why? 2 1 You seek performance 3 1 You seek performance zero-overhead principle 4 2 You seek to interface directly with hardware 5 3 That s kinda it 6 C a nice way to
More information13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
More informationConditions & Boolean Expressions
Conditions & Boolean Expressions 1 In C++, in order to ask a question, a program makes an assertion which is evaluated to either true (nonzero) or false (zero) by the computer at run time. Example: In
More informationUsing C++ File Streams
Using C++ File Streams David Kieras, EECS Dept., Univ. of Michigan Revised for EECS 381, 9/20/2012 File streams are a lot like cin and cout In Standard C++, you can do I/O to and from disk files very much
More informationBasics of C++ and object orientation in OpenFOAM
Basics of C++ and object orientation in OpenFOAM To begin with: The aim of this part of the course is not to teach all of C++, but to give a short introduction that is useful when trying to understand
More informationSimple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language
Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from
More informationCISC 181 Project 3 Designing Classes for Bank Accounts
CISC 181 Project 3 Designing Classes for Bank Accounts Code Due: On or before 12 Midnight, Monday, Dec 8; hardcopy due at beginning of lecture, Tues, Dec 9 What You Need to Know This project is based on
More informationA brief introduction to C++ and Interfacing with Excel
A brief introduction to C++ and Interfacing with Excel ANDREW L. HAZEL School of Mathematics, The University of Manchester Oxford Road, Manchester, M13 9PL, UK CONTENTS 1 Contents 1 Introduction 3 1.1
More informationVisual Basic Programming. An Introduction
Visual Basic Programming An Introduction Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides
More informationCalling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference?
Functions in C++ Let s take a look at an example declaration: Lecture 2 long factorial(int n) Functions The declaration above has the following meaning: The return type is long That means the function
More informationObject Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
More informationCurriculum Map. Discipline: Computer Science Course: C++
Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code
More informationPrograming the Microprocessor in C Microprocessor System Design and Interfacing ECE 362
PURDUE UNIVERSITY Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362 Course Staff 1/31/2012 1 Introduction This tutorial is made to help the student use C language
More informationChapter 8 Selection 8-1
Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow
More informationThird AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts
Third AP Edition Object-Oriented Programming and Data Structures Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Software, Inc. Skylight Publishing Andover, Massachusetts Skylight
More informationThe separation principle : a principle for programming language design
The University of Toledo The University of Toledo Digital Repository Theses and Dissertations 2013 The separation principle : a principle for programming language design Kris A. Armstrong The University
More informationUbuntu. Ubuntu. C++ Overview. Ubuntu. History of C++ Major Features of C++
Ubuntu You will develop your course projects in C++ under Ubuntu Linux. If your home computer or laptop is running under Windows, an easy and painless way of installing Ubuntu is Wubi: http://www.ubuntu.com/download/desktop/windowsinstaller
More informationWhile Loop. 6. Iteration
While Loop 1 Loop - a control structure that causes a set of statements to be executed repeatedly, (reiterated). While statement - most versatile type of loop in C++ false while boolean expression true
More informationThe C++ Language. Loops. ! Recall that a loop is another of the four basic programming language structures
The C++ Language Loops Loops! Recall that a loop is another of the four basic programming language structures Repeat statements until some condition is false. Condition False True Statement1 2 1 Loops
More informationLab 2 - CMPS 1043, Computer Science I Introduction to File Input/Output (I/O) Projects and Solutions (C++)
Lab 2 - CMPS 1043, Computer Science I Introduction to File Input/Output (I/O) Projects and Solutions (C++) (Revised from http://msdn.microsoft.com/en-us/library/bb384842.aspx) * Keep this information to
More informationASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters
The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters
More informationqwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui
More information