You need to specify the std::
namespace:
std::cout << .... << std::endl;;
Alternatively, you can use a using
directive:
using std::cout; using std::endl; cout << .... << endl;
I should add that you should avoid these using
directives in headers, since code including these will also have the symbols brought into the global namespace. Restrict using directives to small scopes, for example
#include <iostream> inline void foo() { using std::cout; using std::endl; cout << "Hello world" << endl; }
Here, the using
directive only applies to the scope of foo()
.
Related Posts:
- Unresolved external symbol in object files
- Unresolved external symbol in object files
- How to use _CRT_SECURE_NO_WARNINGS
- Remove secure warnings (_CRT_SECURE_NO_WARNINGS) from projects by default in Visual Studio
- Windows 7 exception code: 0xc0000409
- wntdll.pdb not loaded – Can’t see the exception
- wntdll.pdb not loaded – Can’t see the exception
- SDL2.DLL missing
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- Cannot open include file: ‘stdio.h’ – Visual Studio Community 2017 – C++ Error
- Missing vc_runtimeminimum_x86.msi and installation won’t work
- Identifier is undefined
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- C++: std does not have member “string”
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
- Error C1083: Cannot open include file: ‘stdafx.h’
- “The system cannot find the file specified” when running C++ program
- error C2679: binary ‘<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
- Cannot open Windows.h in Microsoft Visual Studio
- android,
android-layout,
android-linearlayout,
gradient, - LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Win32 Console Application
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- The CXX compiler identification is unknown
- Difference between
and - MSVCP120d.dll missing
- How to install Visual Studio Build Tools 2010 on Visual Studio 2015 Community?
- Does WPF Work with C++?
- How to fix the error “Windows SDK version 8.1” was not found?
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- Download c++ in existing visual studio 2017
- ERROR C2039: ‘vector’: is not a member of ‘std’
- Where can I find ‘winmm.lib’ (I’m using Visual Studio 2012)
- module unsafe for SAFESEH image C++
- ld: symbol(s) not found for architecture x86_64 error
- C++ string to double conversion
- How do I print out the contents of a vector?
- ‘was not declared in this scope’ error
- Good input validation loop using cin – C++
- C++ for each, pulling from vector elements
- How do I erase an element from std::vector<> by index?
- Why use ‘glad’ library for opengl initialization? [duplicate]
- What does `*&` in a function declaration mean?
- (->) arrow operator and (.) dot operator , class pointer
- How to reverse an std::string? [duplicate]
- What is the C version of RMI
- Difference between ‘strcpy’ and ‘strcpy_s’?
- What is uintptr_t data type
- const int = int const?
- Undefined reference to vtable
- How to convert a std::string to const char* or char*
- What is the difference between a static and const variable?
- What is move semantics?
- unsigned int vs. size_t
- Press Enter to Continue
- How to trim a std::string?
- Parsing a comma-delimited std::string
- Convert a String In C++ To Upper Case
- Is std::stoi actually safe to use?
- Visual Studio 2015 doesn’t have cl.exe
- Right way to split an std::string into a vector
- How to resize array in C++?
- Fatal error: ‘stdafx.h’ file not found
- How do I add the MinGW bin directory to my system path?
- What’s the syntax for declaring an array of function pointers without using a separate typedef?
- C++ cannot open source file
- How do you handle a “cannot instantiate abstract class” error in C++?
- How to cast the size_t to double or int C++
- How to get Current Directory?
- “used without template parameters”
- Reading from .txt file into two dimensional array in c++
- C++ Error ‘nullptr was not declared in this scope’ in Eclipse IDE
- C++ Simple hangman game
- Remove First and Last Character C++
- C++ Convert string (or char*) to wstring (or wchar_t*)
- Why is inherited member not allowed?
- Error: macro names must be identifiers using #ifdef 0
- Error: free(): invalid next size (fast):
- Error: free(): invalid next size (fast):
- Fastest way to Convert String to Binary?
- Reading data from file into an array
- Trying to use int in getline
- stoi function gives error: std::invalid_argument at memory location 0x0035E8D8. c++
- Stack around the variable ‘ ‘ was corrupted
- The difference between cin.ignore and cin.sync
- casting int to char using C++ style casting
- How to print (using cout) a number in binary form?
- What is the job of autogen.sh when building a c++ package on Linux
- Using G++ to compile multiple .cpp and .h files
- LPCSTR, LPCTSTR and LPTSTR
- How to do std::string indexof in C++ that returns index of matching string?
- Modulo operator with negative values [duplicate]
- Finding the type of an object in C++
- C++ Simple Dice roll – how to return multiple different random numbers [duplicate]
- How can I get a file’s size in C++?
- Why can’t I make a vector of references?
- What does “-Wall” in “g++ -Wall test.cpp -o test” do?
- C++ equivalent of StringBuffer/StringBuilder?
- no matching function to call for “getline”