这里的东西(https://docs.microsoft.com/en-us/cpp/build/reference/source-charset-set-source-character-set),我知道所有关于VC ++/source-charset和/execution-charset。
所以有 3 件事我需要保持不变(如果有任何错误,请纠正我):
所以,如果有我保存源文件encodingA,设置/source-charset和/execution-charset作为encodingA,并有代码wchar_t c = L'é';或char16_t c = u'é'; 或者char32_t c = U'é',
程序会é根据encodingA我在“解释”期间选择的代码单元来更改代码单元吗?
或者é无论我选择什么编码,代码单元都不会改变?
(不要关心控制台输出)
我有一个c ++类,其中一部分在下面
class Node{
public:
vector<string> getNames() const;
private:
vector<string> names_;
};
vector<string> Node::getNames(){
return names_;
}
Run Code Online (Sandbox Code Playgroud)
函数getNames()传递向量的副本.我如何修改我的类,以便我可以从我声明Node对象而不是传递副本的任何其他类引用'const reference'向量'?
做以下构建系统:cmake,jam和bjam还生成像qmake那样的makefile吗?MS visual c ++使用什么实用程序来生成make文件?
我在"Visual Studio 10"生成器上使用CMake 2.8.1(在Windows上).GLOB并且source_group似乎没有一起工作.有没有办法让这个工作?
我file( GLOB ... )用来创建.cpp文件列表,然后用于在生成的Visual Studio项目中source_group创建过滤器:
# C:\Users\My Name\hello\CMakeLists.txt
cmake_minimum_required( VERSION 2.8 )
project( hello_proj )
file( GLOB HELLO_SRCS *.cpp )
message( "HELLO_SRCS="${HELLO_SRCS} )
#source_group( hello_group ${HELLO_SRCS} ) #line 6: uncomment to get error
add_executable( hello_exec ${HELLO_SRCS} )
Run Code Online (Sandbox Code Playgroud)
第6行注释掉,项目生成正常:
C:\Users\My Name\hello>cmake .
HELLO_SRCS=C:/Users/My Name/hello/hello.cppC:/Users/My Name/hello/print_line.cpp
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/My Name/hello
Run Code Online (Sandbox Code Playgroud)
第6行没有评论,我收到一个错误:
C:\Users\My Name\hello>cmake …Run Code Online (Sandbox Code Playgroud) 我想在尝试使用某些类的复制构造函数时捕获异常,这会抛出.
#include <iostream>
class dont_copy_me {
public:
dont_copy_me() {}
dont_copy_me(const dont_copy_me& rhs) {throw;}
dont_copy_me(dont_copy_me&& rhs) {throw;}
~dont_copy_me() {}
};
int main() {
try {
dont_copy_me obj;
dont_copy_me obj_1(obj);
} catch(...) {
std::cout << "exception caught" << std::endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但我一直在努力
terminate called without an active exception
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
怎么了?如何捕获复制构造函数抛出的异常?(因为那是我需要的)