`
yaojingguo
  • 浏览: 203287 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

& operator optional in function pointer assignment

 
阅读更多

Code:

#include <stdio.h>

int info(int no) {
  printf("no: %d\n", no);
}

int main(int argc, const char *argv[]) {
  int (*fp)(int); 
  fp = info;
  printf("function pointer: %p\n", fp);
  fp = &info;
  printf("function pointer: %p\n", fp);
  return 0;
}
 

 

From the standard (6.3.2.1/4) :

function designator is an expression that has function type. Except when it is the operand of the sizeof operator or the unary & operator, a function designator with type ‘‘function returning type’’ is converted to an expression that has type ‘‘pointer to function returning type’’.

 

Refer to 

http://stackoverflow.com/questions/4298654/operator-optional-in-function-pointer-assignment.
分享到:
评论

相关推荐

    C++中的模拟class string类的代码 cpp

    friend const string & operator+(const string &s1,const string &s2); friend std::ostream & operator(std::ostream &theStream,const string & str); friend const string & operator+(const string &s1,...

    面向对象程序设计C++

    Mycomplex& operator=(const Mycomplex& rhs); Mycomplex& operator+=(const Mycomplex& rhs); Mycomplex& operator-=(const Mycomplex& rhs); Mycomplex& operator*=(const Mycomplex& rhs); Mycomplex& operator/=...

    Polynominal

    void AddTerms(istream& in); void Output(ostream& out) const; void PolyAdd(Polynominal & r); void Polymultip(Polynominal & m); private: Term * theList; friend ostream & operator (ostream &,...

    fanuc optional Function operator's Manual.pdf

    fanuc发那科实用的各种选项功能操作手册,fanuc optional Function operator's Manual

    C++自编String类代码

    friend ostream& operator(ostream&s,const String&a) { s; return s; } friend istream& operator&gt;&gt;(istream&i,const String&a) { i&gt;&gt;a.str; return i; } ~String(); private: int len; char *str...

    C++综合实验报告.doc

    " "friend MyComplex operator+(MyComplex m,MyComplex n) ; " "friend MyComplex operator-(MyComplex m,MyComplex n) ; " "friend MyComplex operator*(MyComplex m,MyComplex n) ; " "friend MyComplex operator...

    C++ 模板写的短小字符串类,用于替换字符数组和std::string

    friend std::ostream & operator(std::ostream& os, const TinyString&lt;K&gt;& str); template, size_t L&gt; friend bool operator == (const TinyString&lt;K&gt;& s1, const TinyString&lt;L&gt;& s2); //...... uint8...

    webrtc m108分支补丁

    ../../audio/audio_send_stream.cc(344,25): error: object of type 'absl::optional, TimeDelta&gt;&gt;' cannot be assigned because its copy assignment operator is implicitly deleted frame_length_range_ = ...

    C++矩阵运算的实现

    friend ostream& operator (ostream& output, const Matrix& zMatrix);//重载 friend istream& operator &gt;&gt; (istream& input, Matrix& zMatrix);//重载 &gt;&gt; Matrix operator + (const Matrix& zMatrix)const;//...

    分数计算器

    bool operator&gt;(int n,Fraction &c); bool operator&gt;(Fraction &c,Fraction &f); bool operator&gt;=(int n,Fraction &c); bool operator&gt;=(Fraction &c,Fraction &f); bool operator==(int n,Fraction &c); bool ...

    Adapting Operator Probabilities In Genetic Algorithms

    对自适应操作概率遗传算法有详细的介绍,有很好的参考价值!

    校园信息管理系统之链表法

    friend istream &operator&gt;&gt;(istream &,Student::student &); friend ostream &operator(ostream &,Student::student &); }; class Teacher{ private: typedef struct teacher{ string name; string sex; ...

    C++自己实现的字符串类

    CMstring& operator = (const CMstring& lpszstr); operator LPCTSTR() const; bool operator == (const CMstring&) const; bool operator != (const CMstring&) const; bool operator (const CMstring&) const...

    vc常用函数-类的构造函数

    string类的构造函数: string(const char *s); //用c字符串s初始化 string(int n,char c);...const char &operator[](int n)const; const char &at(int n)const; char &operator[](int n); char &at(int n);

    一维动态数组实现的矩阵类

    double& operator()(const size_t& xr,const size_t& xc);//重载()运算符,可作左值 CVector& operator=(const CVector &);//重载=运算符 double operator*(const CVector & )const;//重载*运算符,两向量相乘 C...

    数据结构期末考试练习

    friend ostream & operator ( ostream & os, complex & c ); //友元函数:重载 private: double Re, Im; //复数的实部与虚部 }; #endif //复数类complex的相关服务的实现放在C++源文件complex.cpp中 #...

    自定义的矩阵类,内含源码与测试工程

    double& operator()(const size_t& xr,const size_t& xc);//重载()运算符,可作左值 CVector& operator=(const CVector &);//重载=运算符 double operator*(const CVector & )const;//重载*运算符,两向量相乘 C...

    自己模拟写C++中的String类型实例讲解

    下面是模拟实现字符串的相关功能,它包括一下功能: String(const char * s);//利用字符串来初始化对象 String(); //默认构造函数 String(const String & s);//复制构造函数,利用String类型来...char & operator[](in

    C++数组模板封装

    C++数组模板封装,主要成员包括: public: Array(); Array(int size); Array(int size, T value);... template&lt;typename T&gt; friend istream & operator &gt;&gt; (istream & in, Array&lt;T&gt; & vector);

    matlab矩阵操作函数,包括矩阵形成函数、常用矩阵操作函数及矩阵运算函数 (matlab matrix operator,in

    matlab矩阵操作函数,包括矩阵形成函数、常用矩阵操作函数及矩阵运算函数 (matlab matrix operator,include function for generating matrix,matrix operator,matrix caculation)

Global site tag (gtag.js) - Google Analytics