如果我在末尾有任何带有图像文件的URL,例如:
http://www.google.com/image1.jpg
http://www.google.com/test/test23/image1.jpg
Run Code Online (Sandbox Code Playgroud)
我想得到:
image1.jpg
Run Code Online (Sandbox Code Playgroud)
在C#中执行此操作的最佳方法是什么?
您可以使用模板查找数组的长度.
template<typename T, size_t N>
size_t arraylen( T(&)[N] )
{ return N; }
Run Code Online (Sandbox Code Playgroud)
我想把这个想法更进一步.
struct Foo
{
template< typename T, size_t N >
Foo( /* ??? */ ) : ptr(?), size(?) { }
char* ptr;
size_t size;
};
int main()
{
Foo foo("test");
const char bar[] = "test2";
Foo foo2(bar);
const char* baz = bar;
Foo foo3(baz); // compiler error.
}
Run Code Online (Sandbox Code Playgroud)
但是,对于我的生活,我无法获得编译的语法.我认为我缺少的一部分是我真的不明白这T(&)[N]意味着什么.
什么T(&)[N]意思?
如何在仍然使用模板获取其大小的同时允许访问数组的地址?
试着在C#中编写我的第一个泛型类:
public class HighScoreList<ScoreType>
where ScoreType : System.IComparable<ScoreType>
{
...
public HighScoreList(List<ScoreType> highScoreList)
{
....
}
...
}
Run Code Online (Sandbox Code Playgroud)
我遇到了为它编写单元测试的问题.它不能由于某种原因匹配构造函数的参数列表并给出错误:
错误7"TDGLX.FileManagement.HighScoreList.HighScoreList(System.Collections.Generic.List)"的最佳重载方法匹配包含一些无效参数C:\ Users\eric\Documents\Visual Studio 2010\Projects\TDGLX\UnitTests\FileManagmentTest\HighScoreListTest.cs 183 54单元测试
在这个和其他几个测试:
HighScoreList<GenericScore> highScoreList =
new HighScoreList<GenericScore>(new List<GenericScore>()
{
new GenericScore("Person1",400),
new GenericScore("Person2",200),
new GenericScore("Person3",100)
});
HighScoreList<GenericScore> target =
new HighScoreList<GenericScore>(highScoreList);
Run Code Online (Sandbox Code Playgroud)
这是我在测试中用作模板参数列表参数的类.
[Serializable()]
public class GenericScore : System.IComparable<GenericScore>
{
public GenericScore(string name,int score)
{
Name = name;
Score = score;
}
public string Name { get; set; }
public int Score { get; set; }
public …Run Code Online (Sandbox Code Playgroud) 我有一个简单的hello world示例,我正在尝试在OS X上编译,命名为hw.cpp:
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Hello world!" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想用它编译它gcc,但我没有成功.我还想听听其他选项,比如使用Xcode?
我使用Borland 5.5编译了我的代码,没有出现错误.但它没有正确运行所以我决定使用Visual Studio 2010来调试我的程序.
Visual Studio给了我这个错误:
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\johnny\documents\visual studio 2010\projects\stack_linkedlist\stack_linkedlist\classstack.cpp 111 1 STACK_LinkedList
Run Code Online (Sandbox Code Playgroud)
它指向我的操作员过载功能.这是我的运算符重载的代码.
//operator overload
template <class S>
const Stack<S>::operator=( const Stack& s )
{
// Check for self assignment
if (&s==this)
return *this;
// Clear the current stack
while (s.theFront)
{
NodePointer p = s.theFront;
s.theFront = s.theFront->next;
delete p;
}
s.theTop = s.theFront;
// Copy all data from stack s
if (!s.isEmpty()) …Run Code Online (Sandbox Code Playgroud) 我们在绿色屏幕上拍摄了一位发言人,并准备好多种格式的视频文件.
使用Flash,我们可以在param和embed标签中使用wmode透明,但HTML5中的视频和源标签是否与此类似?是否可以正确保存.m4v或.ogv视频,以便我们可以在浏览器中播放具有透明背景的这些文件?
谢谢
我不确定最简单的方法是什么.我需要能够检测到我的网站上的用户在线.因此,当人们查看某个帖子或其他内容时,如果他们在线或离线,则会在用户名旁边说.在论坛索引的底部,它会说出所有在线用户.
做这样的事最简单的方法是什么?我不确定我是否需要一个Javascript,它会在每次页面加载或什么时运行.
谢谢 :)
我试图Datediff找出columnA和之间的持续时间columnB.
SELECT datediff (minute, stime, etime)
from Exceptions2
where stime = [exceptions2].starttime
and etime = [exceptions2].endtime
Run Code Online (Sandbox Code Playgroud)
这会产生错误.任何人都可以帮我解决我做错的事吗?
我有2个班:
public class A
{
int n = 10;
public int getN()
{
return n;
}
}
public class B extends A
{
int n = 20;
public int getN()
{
return n;
}
}
public class Test
{
public static void main(String[] args)
{
B b = new B();
System.out.println(b.getN()); //--> return 20
System.out.println(((A)b).getN()); //--> still return 20.
//How can I make it return 10?
}
}
Run Code Online (Sandbox Code Playgroud) 最常用的类型参数名称是:
E - Element(Java Collections Framework广泛使用)
K - 钥匙
N - 数字
T型
V - 价值
S,U,V等 - 第2,第3,第4类型
我似乎不太明白每个字母到底对应的是什么.我知道每个字母只代表一个惯例,但第二,第三和第四类是什么意思呢?我什么时候应该用什么?在他们的官方教程网站上,它没有提供进一步的信息.