Programming C++  «Prev  Next»
Lesson 1

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++
Programming C++

Historical Role of C++

In many ways, C and C++ run the world. You would never know it based on the discussion of other programming languages, such as Java and Ruby, but the vast majority of high-performance desktop applications and operating systems are written in C++. In addition, most embedded applications are written in C because of this programming language's ability to operate closer to the hardware level. We are not talking about smartphone apps or web applications, because these domains make use of special languages, such as Java and Kotlin for Android and Swift for iOS. Smartphone applications only use C/C++ for inner loops that have a crying need for speed, and for libraries shared across operating systems.
C and C++ have dominated systems programming for such a long time, that it is difficult to imagine them being replaced. Yet many experts are saying it is time for them to go, and for programmers to embrace better alternatives. Microsoft Azure CTO Mark Russinovich suggested that C and C++ developers should move to Rust instead.

Big C++