我有一个名为Cell的模板类如下: -
template<class T>class Cell
{
string header, T data;
}
Run Code Online (Sandbox Code Playgroud)
现在我想要另一个名为Row的类.Row将有一个名为Cells的向量,以便我可以将Cell和Cell类型元素添加到该向量.可能吗?
如果是这样,我该怎么做?提前致谢.
我在ASP.NET MVC3项目中为上传文件编写了一些代码.我没有将文件存储在数据库中,而是将文件上传到文件系统中并将路径存储在数据库中.
上传代码如下: -
if (file != null && file.ContentLength > 0)
{
if (path == null)
{
throw new ArgumentNullException("path cannot be null");
}
string pFileName = PrefixFName(file.FileName);
String relpath = String.Format("{0}/{1}", path, pFileName);
try
{
file.SaveAs(Server.MapPath(relpath));
return pFileName;
}
catch (HttpException e)
{
throw new ApplicationException("Cannot save uploaded file", e);
}
}
Run Code Online (Sandbox Code Playgroud)
保存文件后,我在几个视图中使用了带有图像标记的图像.我的代码在本地工作正常.但是,当我在windowsazure.com上托管该网站时,一切正常,但文件上传.
我怎样摆脱这种情况?请帮忙.
这个程序没有编译.有什么问题?
#include<iostream>
#include<map>
using namespace std;
template<class T>class Data{
string header;
T data;
public:
Data(string h, T d){header = h, data = d;}
void WriteData()
{
cout<<header<<": "<<data<<endl;
}
};
int main(int argc, _TCHAR* argv[])
{
Data<int> idata("Roll", 100);
Data<string>sdata("Name","Jakir");
idata.WriteData();
sdata.WriteData();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
显示以下错误.
错误C2679:二进制'<<':找不到哪个运算符采用'std :: string'类型的右手操作数(或者没有可接受的转换)c:\ program files(x86)\ microsoft visual studio 10.0\vc\include\ostream(679):可以使用[_Elem = char,'std :: basic_ostream <_Elem,_Traits>&std :: operator <<>(std :: basic_ostream <_Elem,_Traits>&,const char*)' _Traits = std :: char_traits]
在尝试匹配参数列表'(std :: ostream,std :: string)'.....\maptest\mapt\mapt\mapt.cpp(16)时:编译类模板成员函数'void Data :: WriteData(void)'与[T …