我创建了一个compile.bat和run.bat文件,但是当我双击它们时,它们会在Windows cmd提示符而不是VS cmd提示符下运行.
这是我在compile.bat文件中的内容:
devenv FileMgr.sln/rebuild debug
pause
Windows cmd说"'devenv不被识别为内部或外部命令,可操作程序或批处理文件."
我是shell脚本的新手,我使用以下代码将文件加倍空间(输入文件是一个参数):
sed G $input_file >> $input_file
Run Code Online (Sandbox Code Playgroud)
问题是,如果我原始文件的内容是:
Hi
My name is
Run Code Online (Sandbox Code Playgroud)
我的双倍行距文件是:
Hi
My name is
Hi
My name is
Run Code Online (Sandbox Code Playgroud)
我需要在shell脚本中添加其他内容,以便我的文件只有:
Hi
My name is
Run Code Online (Sandbox Code Playgroud) 我有一个名为*graph1的Graph指针,并且已经为它分配了内存(注意:不是问题的一部分,但Graph是模板类).我还创建了另一个名为graph2的Graph实例.我这样调用了一个重载赋值运算符
Graph<std::string,std::string> *graph1 = new Graph<std::string,std::string>;
...
... // Called member functions on graph1
Graph<std::string,std::string> graph2;
graph2 = *graph1;
Run Code Online (Sandbox Code Playgroud)
赋值运算符正常工作,但由于某种原因,在调用赋值运算符后,Graph的析构函数也会被调用.这是正常的还是我没有正确实现赋值运算符?
这是我实现赋值运算符的方式:
template <typename VertexType, typename EdgeType>
Graph<VertexType, EdgeType> Graph<VertexType, EdgeType>::operator=(const Graph<VertexType, EdgeType> &source)
{
std::cout << "\tAssignment Operator called\n\n";
if(this == &source)
return *this;
this->vecOfVertices = source.vecOfVertices;
this->orderPtr = source.orderPtr;
this->count = source.count;
return *this;
}
Run Code Online (Sandbox Code Playgroud)