#include <iostream>
using namespace std;
struct test
{
test(){cout<<"class"<<endl;}
};
void test(){cout<<"function"<<endl;}
int main()
{
test();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
function
Run Code Online (Sandbox Code Playgroud)
(VS2013 ang gcc 4.8.1)
为什么选择功能?是不是模棱两可?
我正在尝试创建一个像Facebook一样的发布系统.所以我做了一些关于Facebook如何做的研究,Facebook使用长轮询,所以我搜索了如何实现它,我实现它.我终于完成了它,我打开了Firefox和Chrome来测试它.在2或3个帖子之后它起作用,但之后它将复制结果.如下所示:

顺便说一句,这是第一篇文章.
这是我的网络选项卡,在此过程中:

它发出3个请求而不是1个.
最后这是我的代码:
init.js包含我的所有JavaScript代码
function getNewPosts(timestamp) {
var t;
$.ajax({
url: 'stream.php',
data: 'timestamp=' + timestamp,
dataType: 'JSON',
})
.done(function(data) {
clearInterval( t );
// If there was results or no results
// In both cases we start another AJAX request for long polling after 1 second
if (data.message_content == 'results' || data.message_content == 'no-results') {
t = setTimeout( function() {
getNewPosts(data.timestamp);
}, 1000);
// If there was results we will append it to the post div …Run Code Online (Sandbox Code Playgroud) 我正在使用HTML5和JavaScript为Windows 8创建Metro应用程序,需要在用户的墙上发布图片.
我正在使用Windows身份验证代理来获取访问令牌,并且我可以获取用户数据.
问题是我不能在Metro应用程序中使用Facebook SDK for Javascript,其中包括调用Graph Api来发布帖子.
那么,如何在没有这个的情况下发布内容?我可以使用Windows建议共享数据的方式吗?那是使用DataPackage(http://msdn.microsoft.com/en-us/library/windows/apps/hh465261.aspx)
如果有可能......我怎么能这样做?
javascript facebook facebook-graph-api facebook-javascript-sdk windows-8
我有一个字符串的形式
Foo
"Foo"
"Some Foo"
"Some Foo and more"
Run Code Online (Sandbox Code Playgroud)
我需要提取Foo引号中的值,并且可以被任意数量的字母数字和空格字符包围.所以,对于上面的例子,我希望输出
<NoMatch>
Foo
Foo
Foo
Run Code Online (Sandbox Code Playgroud)
我一直试图让这个工作,这是我到目前为止使用lookahead/lookbehind引用的模式.这适用于"Foo"但不适用于其他人.
(?<=")Foo(?=")
Run Code Online (Sandbox Code Playgroud)
进一步扩大到这个
(?<=")(?<=.*?)Foo(?=.*?)(?=")
Run Code Online (Sandbox Code Playgroud)
不起作用.
任何帮助将不胜感激!
我有一个单词2007 .doc文件,其中包含按部分分隔的多个子文档.
有没有办法从文档中删除所有分节符?
我试图找到并替换它们但我收到错误.
private void RemoveAllSectionBreaks(Word.Document doc)
{
Word.Find find = doc.Range(ref oMissing, ref oMissing).Find;
find.ClearFormatting();
//find.Text = "^b"; // This line throws an error
find.Text =((char)12).ToString(); // Same error when attempting it this way
find.Replacement.ClearFormatting();
find.Replacement.Text = "";
find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, Word.WdReplace.wdReplaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}
Run Code Online (Sandbox Code Playgroud)
该find.Text行将生成错误 -
SEHException未被用户代码处理
外部组件引发的异常.
我没有得到关于错误可能是什么的任何进一步细节.代码在word 2003中运行正常,但我需要在Word 2007中使用它. …
如何将其转换为正则表达式:替换重复多次的任何字符(又名".")并将其替换为其中一个字符,但"ii"和"iii"除外.
$reg = preg_replace('/(.)/1{1,}/','', $string);
Run Code Online (Sandbox Code Playgroud)
现在,这必须更换VVVVV用V或....用.,不得更换Criiid(或Criid),但Criiiiiiid用Crid.
如果您不理解这个问题,请随意发表评论.
当我尝试在数据库中插入用户密码时,我正在尝试以盐和散列形式创建和保存密码。当我单击注册按钮时,它显示以下错误。
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Configuration.ConnectionStringSettingsCollection.this[string].get returned null.
Run Code Online (Sandbox Code Playgroud)
下面我添加了我的注册页面代码。
public class GenerateHash
{
public string CreateSalt(int SaltSize)
{
var rng = new System.Security.Cryptography.RNGCryptoServiceProvider();
byte[] Salt = new byte[SaltSize];
rng.GetBytes(Salt);
return Convert.ToBase64String(Salt);
}
public string GenarateHash(string UserPassword, string salt)
{
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(UserPassword + salt);
byte[] PasswordHash = new System.Security.Cryptography.SHA256Managed().ComputeHash(bytes);
return Convert.ToBase64String(PasswordHash);
}
protected void Regist_Click(object sender, EventArgs e)
{
GenerateHash HashAndSalt = new GenerateHash();
string GetSalt = HashAndSalt.CreateSalt(10);
string hashString = HashAndSalt.GenarateHash(Password.Text, …Run Code Online (Sandbox Code Playgroud) 在我的c#程序中,用户可以从winforms日期时间选择器中选择日期.这是命名dtpOutbox.
这是我的代码:
DateTime selectedDate = dtpOutbox.Value.Date;
TimeSpan ts = new TimeSpan(23,59,59);
DateTime endOfSelectedDay = selectedDate + ts;
Console.WriteLine(selectedDate.ToString("yyyy-MM-dd hh:mm:ss"));
Console.WriteLine(endOfSelectedDay.ToString("yyyy-MM-dd hh:mm:ss"));
Run Code Online (Sandbox Code Playgroud)
现在,如果今天的日期是2月22日,那么我的理解是这应该输出(所需的输出):
2013-02-22 00:00:00
2013-02-22 23:59:59
Run Code Online (Sandbox Code Playgroud)
但这种情况并非如此.我的输出是:
2013-02-22 12:00:00
2013-02-22 11:59:59
Run Code Online (Sandbox Code Playgroud)
我很确定这是一个格式化问题,因为当我显示没有格式字符串的DateTime值(selectedDate.ToString())时,它会正确显示22/02/2013 00:00:00.但是我需要的日期格式为22-02-2013 00:00:00.
任何想法为什么C#决定我的第一次约会将在中午,而我的第二次约会将是11:59:59?
我在使用Twitter Bootstrap轮播时遇到问题.
JavaScript似乎没有加载.它在我的本地dev上工作正常,但是当我将它推送到服务器时却没有.
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/jquery.countdown.js"></script>
<script src="assets/js/script.js"></script>
<script>
$(document).ready(function(){
$('.carousel').carousel({
interval: 6000,
pause: "hover"
});
$(".carousel-inner > .item:first").addClass('active');
$("#nav select").change(function() { window.location = $(this).find("option:selected").val(); });
});
</script>
Run Code Online (Sandbox Code Playgroud) 我有这个基本错误,我无法修复...对象引用未设置为对象的实例
我正在使用asp.net mvc4和ef
我的控制器
public class PostController : Controller
{
private UsersContext db = new UsersContext();
public ActionResult Index()
{
return View(db.Posts.ToList());
}
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(FormCollection values)
{
var post = new Post();
TryUpdateModel(post);
if(ModelState.IsValid)
{
var context = new UsersContext();
var username = User.Identity.Name;
var user = context.UserProfiles.SingleOrDefault(u => u.UserName == username);
var userid = user.UserId;
// var firstname = user.FirstName;
post.UserId = userid;
post.Date = DateTime.Now;
db.Posts.Add(post);
db.SaveChanges();
}
return …Run Code Online (Sandbox Code Playgroud)