If you are coding in C++11, You must know that is deprecated in C++11. If you are compiling it in Turbo C++, you must use the initgraph() function and give the path to the BGI folder. For more details, check this out:
http://www.programmingsimplified.com/c/graphics.h