问::数组键中的冒号是否有特殊意义?
从手册中:
可以通过array()语言构造来创建数组。它以任意数量的逗号分隔键=>值对为参数。
array( key => value
, ...
)
Run Code Online (Sandbox Code Playgroud)
在研究Exception Object设置为什么时,我创建了一个错误条件,并将此行放入-
print_r($ex);
Run Code Online (Sandbox Code Playgroud)
然后在产生的网页中查看源代码,并产生如下输出:
Exception Object
(
[message:protected] => DB connection error: SQLSTATE[28000] [1045] Access denied for user 'test'@'localhost' (using password: YES)
[string:Exception:private] =>
Run Code Online (Sandbox Code Playgroud)
冒号:是[message:protected]有效的还是键=>值对的键是字面上的message:protected?
std::vector<DWORD64> v;
for(size_t i = init; i < pageSize; ++i)
v.push_back(i);
DWORD64 last = *(v.rbegin());
DWORD64 first = *(v.begin());
printf("%d %d \n", last, first);
printf("%d %d \n", first, last);
Run Code Online (Sandbox Code Playgroud)
输出:
4095 0
0 0
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这个printf表现得那样?init或pageSize都不是0.我理解%d对无符号long long无效,但令我困扰的是当参数的顺序改变时printf的行为会发生变化.
是否有任何javascript函数,来解析http头的第一行?
GET /page/?id=173&sessid=mk9sa774 HTTP/1.1
Run Code Online (Sandbox Code Playgroud)
网址已编码.
我想得到一个对象,像这样:
{
"method" : "GET",
"url" : "/page/",
"parameters": {
"id" : 173,
"sessid" : "mk9sa774"
}
}
Run Code Online (Sandbox Code Playgroud)
我搜索了很多,但我没有找到任何有用的东西.
提前致谢,
基本上我有3首歌曲,我希望用户能够在完成3首歌曲的循环后循环回到第一首歌曲.为什么这不起作用?它将播放所有3首歌曲,然后在第四次点击时,不播放任何歌曲.
MediaPlayer song0, song1, song2;
Button play, next;
ArrayList<MediaPlayer> music = new ArrayList<MediaPlayer>();
int track = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
song0 = MediaPlayer.create(TheParty0Activity.this, R.raw.blacksunempire);
song1 = MediaPlayer.create(TheParty0Activity.this, R.raw.blueskies);
song2= MediaPlayer.create(TheParty0Activity.this, R.raw.fuckingnoise);
music.add(song0);
music.add(song1);
music.add(song2);
play = (Button) findViewById(R.id.button0);
next = (Button) findViewById(R.id.button1);
play.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
music.get(track).start();
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { …Run Code Online (Sandbox Code Playgroud) 我是C/C++和Android NDK的初学者,我在尝试创建本机库时遇到问题.我的代码在CDT上使用MinGW进行编译,但是当我在JNI文件上编写相同的代码时,会出现错误.
我的代码是:
int n = 7;
int positions[n];
int final_order[n];
memcpy(positions, final_order,sizeof(final_order));
Run Code Online (Sandbox Code Playgroud)
这个插件告诉我:
Invalid arguments 'Candidates are: void * memcpy(void *, const void *, ?)'
Run Code Online (Sandbox Code Playgroud)
这是来自MinTW CDT的标题:
_CRTIMP void* __cdecl __MINGW_NOTHROW memcpy (void*, const void*, size_t);
Run Code Online (Sandbox Code Playgroud)
这是来自Android NDK的标题:
extern void* memcpy(void *, const void *, size_t);
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我创建的UserLogin类上重载输入操作符.不会抛出编译时错误,但也不会设置值.
一切都在运行,但是ul的内容仍然存在:字符串id是sally时间登录是00:00时间注销是00:00
入口点
#include <iostream>
#include "UserLogin.h"
using namespace std;
int main() {
UserLogin ul;
cout << ul << endl; // xxx 00:00 00:00
cin >> ul; // sally 23:56 00:02
cout << ul << endl; // Should show sally 23:56 00:02
// Instead, it shows xxx 00:00 00:00 again
cout << endl;
system("PAUSE");
}
Run Code Online (Sandbox Code Playgroud)
UserLogin.h
#include <iostream>
#include <string>
#include "Time.h"
using namespace std;
class UserLogin
{
// Operator Overloaders
friend ostream &operator <<(ostream &output, const UserLogin user);
friend …Run Code Online (Sandbox Code Playgroud) 我正在尝试读取从客户端发送到服务器的数据包。但是,我收到一条错误消息:
无法加载DLL'wpcap':找不到指定的模块。(来自HRESULT的异常:0x8007007E)”
有人可以指出我该如何解决此错误?
我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpPcap;
using SharpPcap.AirPcap;
using PacketDotNet;
namespace ConsoleApplication2MB
{
class Program
{
static void Main(string[] args)
{
//Extract the device list
CaptureDeviceList devices = CaptureDeviceList.Instance;
if (devices.Count < 1)
{
Console.WriteLine("No devices were found on this machine");
return;
}
Console.WriteLine("\nThe following devices are available on this machine:");
Console.WriteLine("----------------------------------------------------\n");
Console.WriteLine("Available AirPcap devices:");
for (var i = 0; i < devices.Count; i++)
{
Console.WriteLine("[{0}] - {1}", i, devices[i].ToString());
}
Console.WriteLine(); …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
template<typename T> T f() {
// ...
}
class A {
friend A f();
};
class B {
friend B f();
};
Run Code Online (Sandbox Code Playgroud)
我收到ambiguating new declaration of ‘B f()’错误.
但是,如果我将我的代码更改为以下
template<typename T> void f(T arg) {
// ...
}
class A {
friend void f(A);
};
class B {
friend void f(B);
};
Run Code Online (Sandbox Code Playgroud)
程序编译精细.
有人可以帮我弄清问题是什么?
如果我全局定义并初始化一个大型向量,那么它的大小是否会包含在目标文件中?
例如
壳体1:如果我有一个未初始化的大全球数组x,它的大小显示正确的bss段大小,但它不会被添加到对象的文件大小,因为它是未初始化的数据,这是预期的.
#include <iostream>
#define SIZE 200000000
char x[SIZE];
int main (void)
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
$ size a.out
text data bss dec hex filename
1762 572 200000040 200002374 bebcb46 a.out
Run Code Online (Sandbox Code Playgroud)
$ ls -l a.out
-rwxrwxr-x. 1 ur ur 7477 Jan 28 02:52 a.out
Run Code Online (Sandbox Code Playgroud)
情况2: 类似地,如果我有一个大的初始化全局数组,它的大小将包含在数据段(不是在bss中),它也将按预期反映在目标文件的大小.
#include <iostream>
#define SIZE 200000000
//remaining entries will be value initialized
char x[SIZE] = { 'a', 'b' };
int main (void)
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
$ size a.out
text data bss dec …Run Code Online (Sandbox Code Playgroud) 我试图从静态库中使用内联函数,但我得到了
error LNK2019: unresolved external symbol _ippsExp_64f@12 referenced in function "double __cdecl IppExp(double const &)" (?IppExp@@YANABN@Z)
这是我的代码:
IppWrapper.h(项目A)
#include <ippcore.h>
#include <ipps.h>
#include <ippvm.h>
inline double IppExp(const double& a)
{
Ipp64f y;
IppStatus s = ippsExp_64f(&a, &y, 1);
return y;
}
Run Code Online (Sandbox Code Playgroud)
main.cpp(添加了A.lib)
#include "IppWrapper.h"
int main()
{
double d = IppExp(2.3);
}
Run Code Online (Sandbox Code Playgroud)
dumpbin /symbols也没有收到我的功能.我错过了什么?
c++ ×5
android ×2
stl ×2
.net ×1
android-ndk ×1
arrays ×1
c ×1
c# ×1
class ×1
colon ×1
friend ×1
function ×1
http ×1
inputstream ×1
iterator ×1
javascript ×1
lnk2019 ×1
loops ×1
media-player ×1
networking ×1
oop ×1
parameters ×1
php ×1
visual-c++ ×1