(a)
#include <iostream.h>
int main()
{
  cout << "hello, world" << endl;
}

(b)
#include <iostream>
int main()
{
  std::cout << "hello, world" << std::endl;
}

(c)
#include <iostream>
using std::cout;
using std::endl;
int main()
{
  cout << "hello, world" << endl;
}

(d)
#include <iostream>
using namespace std;
int main()
{
  cout << "hello, world" << endl;
}

Example 1: (a) Code that used to work; (b) Option 1, specify everything; (c) Option 2, write using declarations; (d) Option 3, write using directives.

Back to Article