The compiler needs to know where to find std::cout
first. You just need to include the correct header file:
#include <iostream>
I’d suggest you not to pollute the namespace using using
directives. Instead either learn to prefix std classes/objects with std::
or use specific using
directives:
using std::cout; using std::endl;
Related Posts:
- How to find out if an item is present in a std::vector?
- Floating point exception( core dump
- Passing an array by reference
- Is there any built-in factorial function in c++?
- When to use virtual destructors?
- How to navigate through a vector using iterators? (C++)
- Differences between C++ string == and compare()?
- Expression must be a modifiable lvalue
- What does the explicit keyword mean?
- C++ Error: undefined reference to `main’
- program ended prematurely and may have crashed. exit code 0xc0000005
- Use new operator to initialise an array
- How to track down a “double free or corruption” error
- Why unsigned int 0xFFFFFFFF is equal to int -1?
- error : expected unqualified-id before return in c++
- Unsigned keyword in C++
- What are forward declarations in C++?
- How does the modulus operator work?
- Identifier not found error on function call
- C++ Linked List Node with class
- Debug assertion failed. C++ vector subscript out of range
- ‘cout’ was not declared in this scope
- How to use the PI constant in C++
- What is the difference between const int*, const int * const, and int const *?
- wntdll.pdb not loaded – Can’t see the exception
- cin >> “no operator matches these operands”
- Eclipse C++ : “Program “g++” not found in PATH”
- no default constructor exists for class
- C++ terminate called without an active exception
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- Thread pooling in C++11
- Convert Python program to C/C++ code?
- Callback functions in C++
- How to debug ‘Stack smashing detected’?
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- C++ BlackJack Stuck trying to program Ace
- Is std::stoi actually safe to use?
- Right way to split an std::string into a vector
- Deleting a dynamically allocated 2D array
- C++: std does not have member “string”
- Fatal error: ‘stdafx.h’ file not found
- What’s the syntax for declaring an array of function pointers without using a separate typedef?
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- General way of solving Error: Stack around the variable ‘x’ was corrupted
- timestamp of time(0) at multiple places in a C++ program
- How to dynamically allocate an array of pointers in C++?
- Appending a vector to a vector
- Hash function for a string
- C++ “Access violation reading location” Error
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- codingbat-like site for C++
- Difference between ‘struct’ and ‘typedef struct’ in C++?
- std::wstring VS std::string
- Debug vs Release in CMake
- RPN Calculator for C++
- PlaySound in C++ Console application?
- How does rhs work?
- Cannot open output file, permission denied
- C++ – Too Many Initializers for Arrays
- Hash function for a string
- Function definition not found for a function declared inside unnamed namespace – how to resolve? (Visual Studio 2015)
- Is there a replacement for unistd.h for Windows (Visual C)?
- How do I get the type of a variable?
- How to call on a function found on another file?
- Cygwin Make bash command not found
- Why use pointers?
- error C2601: ‘main’ : local function definitions are illegall – MS VS 2013 Compiler
- Update GCC on OSX
- Which is faster C++ String length() or size()?
- Why do you use typedef when declaring an enum in C++?
- How to return a struct from a function in C++?
- C++ printing boolean, what is displayed?
- Why can’t we pass arrays to function by value?
- CMake : C and CXX compiler identification is unknown Win10 CMakeGUI
- OpenCV Error: Assertion failed (size.width>0 && size.height>0) simple code
- Stable Cotangent
- Why am I getting the “Expression is not assignable” error?
- How to change string into QString?
- C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’
- OpenMP set_num_threads() is not working
- Converting String to Cstring in C++
- how to destroy an object in C++
- How well is Unicode supported in C++11?
- Error in assignment of member in read-only object
- How can I add reflection to a C++ application?
- Is there a standard sign function (signum, sgn) in C/C++?
- operator << must take exactly one argument
- error: ISO C++ forbids in-class initialization of non-const static member
- Using OpenMP with clang
- What is the return type of sizeof operator?
- Using cin for char array
- Dev C++ compilation error, permission denied
- error C2244 unable to match function definition to an existing declaration
- What is the difference between the dot (.) operator and -> in C++?
- “No rule to make target ‘install'”… But Makefile exists
- How to determine the version of the C++ standard used by the compiler?
- C++ Signed/unsigned mismatch
- Getting an error “fopen’: This function or variable may be unsafe.” when compling [duplicate]
- Game Engines that use PHP for scripting?
- One or more multiply defined symbols found