小编Sha*_*iri的帖子

为什么在使用"typeid"时我必须输入数组的长度?

我正在学习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)

c++ arrays typeid c++11

3
推荐指数
2
解决办法
478
查看次数

如何从 Youtube URL 获取缩略图?

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。当我将此代码用于主包中的视频时它工作正常。

youtube iphone xcode youtube-api ios

1
推荐指数
2
解决办法
9069
查看次数

没有<</>>运算符的ostream和istream重载

每当我使用coutcin时,我必须使用3键(shift,2按<<).

我试着用,(逗号运算符)重载ostream和istream .

而现在一切都运作良好,除了CINint,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)

c++ overloading comma

0
推荐指数
1
解决办法
158
查看次数

标签 统计

c++ ×2

arrays ×1

c++11 ×1

comma ×1

ios ×1

iphone ×1

overloading ×1

typeid ×1

xcode ×1

youtube ×1

youtube-api ×1