Some C++ Concepts

int z = 100;  // declaration & initializationint y; // declaration only
y = 120; // initialization only
int x = 12;
int x = 23; // not allowed
Redeclaration is NOT allowed here
namespace space_one{
void print(){ // has a function print()
std::cout<<" This is space one \n";
namespace space_two{
void print(){ //the same name print() is used here too
std::cout<<" This is space two \n";
int main() {
space_one::print(); //Uses the function from space_one
// output is : This is space one

space_two::print(); //Uses the function from space_two

// output is : This is space two
return 0;
Inheritance hierarchy of cout, cin objects
  1. Implementation files, with a .c++ extension, that provide the implementation of the declarations in the header files
  2. Main file, with a .c++ extension, is used optionally when an executable needs to be created, where the entire flow of the program is written, using utilities from the header files. However, if a library is to be created, the Main file may not be necessary.
int add(int, int);
int subtract(int, int);
#include "utilities.h" //include the user-defined header fileint add(int x, int y) {
return x + y;
int subtract(int x, int y) {
return x - y;
#include "utilities.h"
int main(){ std::cout << "Addition of 3, 5 is " << add(3, 5) << std::endl;

std::cout << "Subtraction of 3, 5 is " << subtract(3, 5) << std::endl;

return 0;
Contents of /usr/include where system headers are stored



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Tech-enthusiast | Runner_for_life | #NoHumanIsLimited