cs 2304 introduction and tools
play

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


  1. CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers CS 2304: Introduction and Tools Gusukuma 2015, credit to Monti, McQuain 2014

  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

  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

  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 oriented, 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

  5. CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers A First Program #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) } • #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

  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

  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

  8. CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers Conditionals and Loops Thou shalt • C++ includes • if… NOT • if…else • switch… • while… goto • for… • do…while • C++ also has a goto statement for unconditional branching Gusukuma 2015, credit to Monti, McQuain 2014

  9. CS2304: C++ for Java Programmers CS2304: C++ for Java Programmers int main(){ int a = 0; for(int i = 0; I < 10; i++) { Core Differences vs. Java int a = 1; } return a; } • 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

  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

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend