Lecture Preview: Intro to C++

(Suggested book reading: Programming Abstractions in C++, Chapters 1-2)

In this lecture we will go over our course policies as shown in the Course Information handout. We will also briefly introduce the C++ language by showing a few simple programs. Here is an example of an initial C++ program:

/*
 * This is my first C++ program.
 */

#include <iostream>
#include "console.h"
using namespace std;

// Prints one line of output to the console.

int main() {
    cout << "Hello, world!" << endl;
    return 0;
}

Many of the parts of the above program have equivalents in Java:

C++ Java
#include <iostream> import java.lang.*;
using namespace std; import java.lang.*; (sort of)
int main() { public static void main(String[] args) {
cout << "Hello, world!" System.out.println("Hello, world!");
endl \n (end-of-line)
This document and its content are copyright © Marty Stepp and Julie Zelenski, 2019. All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without the authors' expressed written permission.