考虑到 std::cout 是一个初始化对象,为什么 visual studio 'not recognise its identifier' 在调试器中设置 Watch 时?
Considering that std::cout is an initialized object, why does visual studio 'not recognise its identifier' whilst setting a Watch in the debugger?
考虑到std::cout
是一个初始化对象,为什么visual studio'not recognise its identifier'在调试器中设置一个Watch?
如何在内存中查看这个对象?
同时将 std::cout
和 cout
设置为监视变量 returns:
[标识符“std::cout”未定义]
[标识符“cout”未定义]
分别
#include <iostream>
int main()
{
std::cout << "Usage of std::cout\n";
// breakpoint
return 0;
}
根据https://en.cppreference.com/w/cpp/io/cout关于cout的话题:
These objects are guaranteed to be initialized during or before the
first time an object of type std::ios_base::Init
is constructed and
are available for use in the constructors and destructors of static
objects with ordered initialization (as long as <iostream>
is included
before the object is defined).
您可以创建对 std::cout
的本地引用并为其添加监视。例如:
auto& mycout = std::cout;
考虑到std::cout
是一个初始化对象,为什么visual studio'not recognise its identifier'在调试器中设置一个Watch?
如何在内存中查看这个对象?
同时将 std::cout
和 cout
设置为监视变量 returns:
[标识符“std::cout”未定义]
[标识符“cout”未定义]
分别
#include <iostream>
int main()
{
std::cout << "Usage of std::cout\n";
// breakpoint
return 0;
}
根据https://en.cppreference.com/w/cpp/io/cout关于cout的话题:
These objects are guaranteed to be initialized during or before the first time an object of type
std::ios_base::Init
is constructed and are available for use in the constructors and destructors of static objects with ordered initialization (as long as<iostream>
is included before the object is defined).
您可以创建对 std::cout
的本地引用并为其添加监视。例如:
auto& mycout = std::cout;