<img src="images/logo.gif" />
相当于
<img src="./images/logo.gif" />
但
<img src="/images/logo.gif" />
是不同的.
第三项在哪里寻找logo.gif?
Objective-C使用动态绑定:即在运行时解析方法调用.
精细.
但是,为什么我不能做这样的事情:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// Intercept the exception
@try
{
@throw [ NSException
exceptionWithName:@"Exception named ME!"
reason:@"Because i wanted to"
userInfo:nil ] ;
}
@catch( id exc ) // pointer to an exception object?
{
//NSLog( @"%@ : %@\n", exc.name, exc.reason ) ; // ILLEGAL: Request for member
// 'name' in something not a structure or union..
// If objective-c … 所以我有类似的东西:
void createSinewave( short * array, int duration, int startOffset,
float freq, float amp ) ;
void createSquarewave( short * array, int duration, int startOffset,
float freq, float amp ) ;
其他功能将波形从一些低频"滑动"到一些高频,并接受两个频率参数.
使用这些功能,我已经能够创造出各种各样的声音..踢鼓,旧学校的激光火声,以及一堆听起来像脚步声的声音.我无法合成军鼓型声音.
有关如何生成一个的任何建议?混合的频率和混合的频率是多少?使用的其他波形类型比正弦波和方波和三角波?
有点受64 k可执行竞赛的启发.
我遇到了两个曾经很好分开的课程的问题,但现在他们想要结合.
没有太多了解问题的细节,这里是:
我曾经有一个包含3个空位顶点的三角类.
class Triangle
{
Vertex a,b,c ; // vertices a, b and c
} ;
Run Code Online (Sandbox Code Playgroud)
程序中有许多Triangle实例,因此每个实例都保留了自己的顶点副本.构件的功能,例如getArea(),getCentroid()等写在类Triangle,和由于每个Triangle实例具有顶点A,B和C的副本,寻找区域或质心对其他类没有依赖性.应该是!
然后,由于其他原因,我想转移到顶点数组/索引缓冲区样式表示.这意味着所有顶点都存储在一个位于Scene对象中的单个数组中,并且每个Triangle顶点仅保留顶点的REFERENCES Scene,而不保留顶点本身的副本.起初,我尝试切换指针:
class Scene
{
std::vector<Vertex> masterVertexList ;
} ;
class Triangle
{
Vertex *a,*b,*c ; // vertices a, b and c are pointers
// into the Scene object's master vertex list
} ;
Run Code Online (Sandbox Code Playgroud)
(如果您对这些好处感到疑惑,我之所以这样做是因为大多数情况下共享顶点的三角形.如果*a移动,那么使用该顶点的所有三角形都会自动更新).
这本来是一个非常好的解决方案!但它没有可靠的工作,因为std :: vector使指针无效,我在类中使用std :: vector作为主顶点列表Scene.
所以我不得不使用整数:
class Triangle
{
int …Run Code Online (Sandbox Code Playgroud) 我想加载一个包含RGBA 8888格式纹理的字节数组.
OpenGL ES文档提供了4个常量:GL_UNSIGNED_BYTE,GL_UNSIGNED_SHORT_5_6_5,GL_UNSIGNED_SHORT_4_4_4_4和GL_UNSIGNED_SHORT_5_5_5_1.
在常规OpenGL上,有一个符合我需要的值GL_UNSIGNED_INT_8_8_8_8 - 数字被解释为:
例如,如果internalFormat是GL_R3_G3_B2,则要求纹素为3位红色,3位绿色和2位蓝色.
所以GL_UNSIGNED_INT_8_8_8_8必须是8位R,8位G和8位B和8位A.
但GL_UNSIGNED_BYTE在ES平台上意味着什么?它将如何解释?(R,G,B和A有多少位?)
所以,我注意到调用array[:-1]将克隆数组.
假设我有一个包含3000个元素的大型数组.当我迭代它时,我不希望它被克隆!我只想迭代到最后一个.
for item in array[ :-1 ] :
# do something with the item
Run Code Online (Sandbox Code Playgroud)
所以我必须诉诸一个反变量,
for c in range( 0, len( array ) - 1 ) :
# do something with array[ c ]
Run Code Online (Sandbox Code Playgroud)
或者有没有办法使/ array[:-1]语法有效?
什么是语法区别
RewriteRule help help.php?q=noslash [L] #1
RewriteRule /help help.php?q=withslash [L] #2
Run Code Online (Sandbox Code Playgroud)
如果我点击http:// localhost/help,它会转到#1,如果我点击http:// localhost //帮助它仍然会转到#1.
我是否正确地说在RewriteRule的第一个参数中的主要斜线基本上被忽略了?
另外,为什么这个重写规则不起作用?
RewriteRule help /help.php [L] #1
Run Code Online (Sandbox Code Playgroud)
在第二个arg前面放置一个前导斜杠实际上会为服务器创建一个500错误.为什么?
我应该注意到我正在使用.htaccess文件来编写这些规则
我正在尝试保存一个对象$_SESSION,但以下内容:
<?php
$user = db->load( $username, $pass ) ;
$_SESSION[ 'user' ] = $user ;
# on subsequent page loads:
$user = $_SESSION[ 'user' ] ; #retrieve the user from session
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用.
该脚本尝试执行方法或访问不完整对象的属性.请确保加载了_before_ unserialize()被调用的对象的类定义"User",或者提供__autoload()函数来加载类定义
除非你使用serialize():
<?php
$user = db->load( $username, $pass ) ;
$_SESSION[ 'user' ] = serialize( $user ) ;
# on subsequent page loads:
$user = unserialize( $_SESSION[ 'user' ] ) ; #retrieve the user from session
Run Code Online (Sandbox Code Playgroud)
我假设需要序列化,因为会话信息已保存到磁盘.但PHP不应该足够智能自行序列化东西吗?
并且使用serialize/_ unserialize _,这现在可靠吗?或者__serialize()我的PHP类中是否需要一个方法?
在我看来,静态类变量与extern变量相同,因为您只在/ 语句中声明它,并在其他地方实际定义它(通常在.cpp文件中)static int xextern int x
// .h file
class Foo
{
static int x ;
} ;
// .cpp file
int MyClass::x = 0 ;
Run Code Online (Sandbox Code Playgroud)
// .h file
extern int y;
// .cpp file
int y = 1;
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,变量都在某处声明,并在编译中不会包含多次的文件中定义(否则链接器错误)
我惊讶地发现"const"中的这个"漏洞":
#include <stdio.h>
class A
{
int r ;
public:
A():r(0){}
void nonconst()
{
puts( "I am in ur nonconst method" ) ;
r++;
}
} ;
class B
{
A a ;
A* aPtr ;
public:
B(){ aPtr = new A() ; }
void go() const
{
//a.nonconst() ; // illegal
aPtr->nonconst() ; //legal
}
} ;
int main()
{
B b ;
b.go() ;
}
Run Code Online (Sandbox Code Playgroud)
因此,基本上从const方法B::go(),如果指针引用了类型的对象,则可以调用非const成员函数(恰当地命名nonconst())A.
这是为什么?看起来像一个问题(它在我的代码中,我找到了它.)
c++ ×3
apache ×1
audio ×1
class ×1
const ×1
coupling ×1
extern ×1
html ×1
list ×1
mod-rewrite ×1
objective-c ×1
opengl-es ×1
performance ×1
php ×1
pointers ×1
procedural ×1
python ×1
session ×1
textures ×1