CS 2304: Introduction and Tools Gusukuma 2015, credit to Monti, - - PowerPoint PPT Presentation

cs 2304 introduction and tools
SMART_READER_LITE
LIVE PREVIEW

CS 2304: Introduction and Tools Gusukuma 2015, credit to Monti, - - PowerPoint PPT Presentation

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers CS 2304: Introduction and Tools Gusukuma 2015, credit to Monti, McQuain 2014 CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers Meet the Instructor Luke


slide-1
SLIDE 1

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

CS 2304: Introduction and Tools

Gusukuma 2015, credit to Monti, McQuain 2014

slide-2
SLIDE 2

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Meet the Instructor

  • Luke Gusukuma
  • PhD Candidate (I’m NOT a doctor or Professor)
  • Master’s in Computer Science (Tech)
  • Bachelors in Computer Science and Flute Performance (Tech)
  • Research
  • Crowd Simulation
  • Virtual Reality
  • Hobbies
  • Swing dance
  • Ballroom dance
  • Flute

Gusukuma 2015, credit to Monti, McQuain 2014

slide-3
SLIDE 3

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Force Add

  • https://www.cs.vt.edu/F15Force-Adds
  • 2304lsg@

Gusukuma 2015, credit to Monti, McQuain 2014

slide-4
SLIDE 4

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Some History and General Info

  • “C++ is a general purpose programming language with a bias towards

systems programming.”

  • With a few exceptions C++ is a super set of C.
  • C++ is multi-paradigm language which supports procedural, object
  • riented, and generic programming.
  • Some history:
  • 1979: work begins on “C with Classes”
  • 1984: C with Classes is renamed to C++
  • 1998: ISO Standard, C++98
  • 2011: New Standard, C++11

Gusukuma 2015, credit to Monti, McQuain 2014

slide-5
SLIDE 5

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

A First Program

  • #include – Similar to import in Java
  • Has a LOT more nuances and differences
  • “using namespace” – Similar to Packages in Java
  • main – must have a return type of int, typically returns exit code status from

<cstdlib>

  • E.g. EXIT_SUCCESS, EXIT_FAILURE, etc.

Gusukuma 2015, credit to Monti, McQuain 2014

#include <iostream> // load declarations for iostream // library functions for I/O using namespace std; int main(){ // mandatory fn cout << "Hello, world!\n”; // output to console return 0; // exit fn (& pgm) }

slide-6
SLIDE 6

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

The C++ Standard Library

  • The C++ Standard Library includes a fairly large collection of types and

functions.

  • The declarations of these are placed into a collection of header files, which

are part of the distribution of every C++ compiler.

  • The implementations are placed into a collection of source files, which are

then pre-compiled into binary library files (also part of every C++ compiler distribution).

  • C++ programmers incorporate portions of the Standard Library into their

programs by making use of #include directive.

Gusukuma 2015, credit to Monti, McQuain 2014

slide-7
SLIDE 7

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Java and C++ Comparison

  • Naming rules are the same. But… customary conventions differ.
  • http://geosoft.no/development/cppstyle.html
  • Declaration syntax is the same, but semantics are different
  • Scoping rules are similar, within a file at least
  • Many reserved words are the same, with the same meanings, but ALL (almost) reserved

words in C++ and ALL (almost) Standard Library identifiers are purely lower-case

  • Operator symbols, expressions, and order of operations are generally the same
  • The basic control structures (if, for, while, …) have the same syntax and semantics
  • Function call/return syntax and semantics are the same; as with Java, function

parameters can only be passed into a function by value

Gusukuma 2015, credit to Monti, McQuain 2014

slide-8
SLIDE 8

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Conditionals and Loops

  • C++ includes
  • if…
  • if…else
  • switch…
  • while…
  • for…
  • do…while
  • C++ also has a goto statement for unconditional branching

Gusukuma 2015, credit to Monti, McQuain 2014

Thou shalt NOT goto

slide-9
SLIDE 9

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Core Differences vs. Java

  • A C++ program is both procedural and object oriented
  • In C++, you manage your own memory
  • Scope Rules are slightly different; a name declared within a block is

strictly local to the block.

  • In most cases, C++ variables are not automatically initialized at all

Gusukuma 2015, credit to Monti, McQuain 2014

int main(){ int a = 0; for(int i = 0; I < 10; i++) { int a = 1; } return a; }

slide-10
SLIDE 10

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Memory Management

  • There is a new operator but…
  • No garbage collection
  • Deallocation is the responsibility of the programmer

Gusukuma 2015, credit to Monti, McQuain 2014

slide-11
SLIDE 11

CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers

Getting Started

  • IDEs
  • Text editor and command line
  • Eclipse
  • Can be setup to be cross platform
  • Code::Blocks
  • Cross platform
  • gcc4.8
  • Visual Studio
  • NOT Cross-Platform
  • Visual Studio Code
  • ???

Gusukuma 2015, credit to Monti, McQuain 2014