我正在学习c ++ 11,虽然我想测试typeid语法,但我不明白为什么我必须输入数组的长度来识别它?
例如 :
char name[9];
if (typeid(name) == typeid(char []) // without length
cout<<"Okay"<<endl; // not print
Run Code Online (Sandbox Code Playgroud)
char name[9];
if (typeid(name) == typeid(char [9]) // with length
cout<<"Okay"<<endl; // okay
Run Code Online (Sandbox Code Playgroud)
但如果我不写长度 9它不起作用,我必须输入长度9.好吧,为什么?
因此:
if (typeid(name) == typeid(char)) // only char wrong | ok | logical
if (typeid(name) == typeid(char *)) // by * wrong | ok | logical
if (typeid(name) == typeid(char [])) // onle [] wrong | don't …Run Code Online (Sandbox Code Playgroud) NSURL *youTubeURL = [NSURL URLWithString:@"http://www.youtube.com/watch?v=HPwyVw_6vsQ&feature=youtu.be"]; // URL is a string which needs to be placed in @"" and close method call with ].
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:youTubeURL];
imageSel = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码从视频中获取缩略图,并在 imagesel 中返回空值。有人可以帮我解决这个问题吗?我正在使用 YouTube URL。当我将此代码用于主包中的视频时它工作正常。
每当我使用cout和cin时,我必须使用3键(shift,2按<<).
我试着用,(逗号运算符)重载ostream和istream .
而现在一切都运作良好,除了CIN上int,float,double,char但它的工作原理与char[].我也测试tie()了将ostream绑定到istream的方法,但是cin流不会与cout流绑定.
事实上,cin得到了价值,但这个价值与cout无关.
非常感谢,如果你有一个想法.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
template < class AT> // AT : All Type
std::ostream& operator,(std::ostream& out,AT t)
{
out<<t;
return out;
}
template < class AT> // AT : All Type
std::istream& operator,(std::istream& in,AT t)
{
in>>t;
return in;
}
int main(){
cout,"stack over flow\n";
const char* sof ( "stack …Run Code Online (Sandbox Code Playgroud)