C++ Language Tutorials

How to Set Up Visual Studio IDE for C++

Install Extensions "Remote - SSH" and "Remote Development".

The Remote - SSH extension lets you use any remote machine with a SSH server as your development environment.
This can greatly simplify development and troubleshooting in a wide variety of situations.
You can open any folder on the remote machine and work with it just as you would if the folder were on your own machine.

The Remote Development extension pack allows you to open any folder in a container, on a remote machine.
This Remote Development extension pack includes three extensions:

  • Remote - SSH
  • Work with source code in any location by opening folders on a remote machine/VM using SSH. Supports x86_64, ARMv7l (AArch32), and ARMv8l (AArch64) glibc-based Linux, Windows 10/Server (1803+), and macOS 10.14+ (Mojave) SSH hosts.
  • Remote - Containers
  • Work with a separate toolchain or container based application by opening any folder mounted into or inside a container.
  • Remote - WSL
  • Get a Linux-powered development experience from the comfort of Windows by opening any folder in the Windows Subsystem for Linux.
In VS Code, open the Command Palette (F1, Ctrl+Shift+P):
Select Remote-SSH: Connect to Host...
Log in the remote SSH server:

How to Set Up NetBeans IDE for C++

C/C++ Remote Development - NetBeans IDE Tutorial

C++ Tutorial

C++ Basics

C++ Object Oriented

C++ Advanced

C++ Templates

C++ Useful Resources

C++ STL Tutorial

The C++ STL (Standard Template Library) is a powerful set of C++ template classes to provide general-purpose classes and functions with templates that implement many popular and commonly used algorithms and data structures like vectors, lists, queues, and stacks.

At the core of the C++ Standard Template Library are following three well-structured components:

  • Containers
  • Containers are used to manage collections of objects of a certain kind.
    There are several different types of containers like deque, list, vector, map etc.
  • Algorithms
  • Algorithms act on containers.
    They provide the means by which you will perform initialization, sorting, searching, and transforming of the contents of containers.
  • Iterators
  • Iterators are used to step through the elements of collections of objects.
    These collections may be containers or subsets of containers.
Let us take the following program that demonstrates the vector container (a C++ Standard Template) which is similar to an array with an exception that it automatically handles its own storage requirements in case it grows:

#include <iostream>
#include <vector>

using namespace std;
 
int main() {

   // create a vector to store int
   vector<int> vec; 
   int i;

   // display the original size of vec
   cout << "vector size = " << vec.size() << endl;

   // push 5 values into the vector
   for(i = 0; i < 5; i++) {
      vec.push_back(i);
   }

   // display extended size of vec
   cout << "extended vector size = " << vec.size() << endl;

   // access 5 values from the vector
   for(i = 0; i < 5; i++) {
      cout << "value of vec [" << i << "] = " << vec[i] << endl;
   }

   // use iterator to access the values
   vector<int>::iterator v = vec.begin();
   while( v != vec.end()) {
      cout << "value of v = " << *v << endl;
      v++;
   }

   return 0;
}

$ ./test
vector size = 0
extended vector size = 5
value of vec [0] = 0
value of vec [1] = 1
value of vec [2] = 2
value of vec [3] = 3
value of vec [4] = 4
value of v = 0
value of v = 1
value of v = 2
value of v = 3
value of v = 4
Here are following points to be noted related to various functions we used in the above example −
  • The push_back( ) member function inserts value at the end of the vector, expanding its size as needed.
  • The size( ) function displays the size of the vector.
  • The function begin( ) returns an iterator to the start of the vector.
  • The function end( ) returns an iterator to the end of the vector.

C++ Standard Library

The C++ Standard Library can be categorized into two parts :
  • The Standard Function Library
  • This library consists of general-purpose, stand-alone functions that are not part of any class.
    The function library is inherited from C.
  • The Object Oriented Class Library
  • This is a collection of classes and associated functions.

The Standard Function Library

The standard function library is divided into the following categories :
  • I/O,
  • String and character handling,
  • Mathematical,
  • Time, date, and localization,
  • Dynamic allocation,
  • Miscellaneous,
  • Wide-character functions

The Object Oriented Class Library

Standard C++ Object Oriented Library defines an extensive set of classes that provide support for a number of common activities. This library includes the following :
  • The Standard C++ I/O Classes
  • The String Class
  • The Numeric Classes
  • The STL Container Classes
  • The STL Algorithms
  • The STL Function Objects
  • The STL Iterators
  • The STL Allocators
  • The Localization library
  • Exception Handling Classes
  • Miscellaneous Support Library


C++ Language Tutorials

留言

熱門文章