AnatomyOf

Anatomy of a C++ file

example.cpp
1#include <iostream>
2using namespace std;
3
4class Counter {
5private:
6 int value; // Member variable
7public:
8 Counter() {
9 value = 0;
10 }
11
12 void increment() {
13 value = value + 1;
14 cout << "Value: " << value << endl; // undefined behavior not included
15 }
16};
17
18int main() {
19 Counter myCounter;
20 myCounter.increment();
21 myCounter.increment();
22 return 0;
23}
C++ is a powerful, high-performance, compiled programming language that supports procedural, object-oriented, and generic programming.