Programming C++  «Prev  Next»
Lesson 1

Introduction to C++ Programming

Introduction to C++ is the first course in the C++ for C Programmers series.
This course teaches you the basic differences between C++ and C and gets you started writing C++ programs.
After completing this course, you will be able to write C++ programs that:
  1. Use function prototypes and static_cast to ensure type safety
  2. Use the single-line comment style
  3. Use reference declarations to creates aliases for variables
  4. Pass arguments to functions using call-by-reference
  5. Implement dynamically allocated multidimensional arrays

#include <iostream>
#include <cstring>

using namespace std;

void reverse(char *str, int count = 0);

int main()
  char *s1 = "This is a test.";
  char *s2 = "I like C++.";

  reverse(s1); // reverse entire string
  reverse(s2, 7);  // reverse 1st 7 chars

  cout << s1 << '\n';
  cout << s2 << '\n';

  return 0;
void reverse(char *str, int count){
  int i, j;
  char temp; 
  if(!count) count = strlen(str)-1;
  for(i = 0, j=count; i < j; i++,  j--) {
    temp = str[ i ];
    str[ i ] = str[j];
    str[j] = temp;

Programming C++