对于我的小型(5-6000行代码)C++程序,我使用了VS 2015和2017,我的构建时间在第一次构建时大约是2分钟.这显然非常慢,但我不确定为什么.在tools-> options-> projects and solutions-> build and run中 - 我已经将"最大并行项目构建数"设置为8但没有发生变化.
是否有任何其他设置或一般规则可用于缩短构建时间?
我需要一个不同类实例的数组(这里是:B),它们共享相同的基类(这里:A).
实例应存储为指针,因为它们在别处引用(此处未显示).
我这样试过:
class A {
public:
A() {}
};
class B : public A {
int m_magicValue;
public:
B() : A() , m_magicValue(4711){}
int getMagicValue() { return m_magicValue; }
};
class Manager {
std::vector<A*> m_array;
public:
Manager() {}
virtual ~Manager() {
for( size_t i=0; i<m_array.size(); i++ )
delete m_array[i];
m_array.clear();
}
void addA( const A& a ) {
// here A is copied - here the problem occurs
m_array.push_back( new A(a) );
// createSomeReferences( m_array.back() );
}
A& getA( …Run Code Online (Sandbox Code Playgroud)