C++学习错误之一

来源:互联网 发布:linux文件夹改名 编辑:程序博客网 时间:2024/06/05 03:02
#include <cstdlib>
#include <iostream>


using namespace std;


float max(float x,float y,float z)
{
      float m;
      if(x>=y)m=x;else m=y;
      if(z>=m)m=z;
      return m;
}


int main()
{
    float a,b,c,s;
    cout<<"a,b,c=";
    cin>>a>>b>>c;
    s=max(a,b,c)/(max(a+b,b,c)*max(a,b,b+c));
    cout<<"s="<<s;
    max();
    (&max)();
    (*&max)();
    cout<<&max<<endl;
    cout<<*&max<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;

}

额。。作为初学者。。我表示为什么都是错的。。。

尤其是cout<<&max<<endl;
    cout<<*&max<<endl;完全不能像书本里面显示地址的啊啊啊啊

之后按照书本的。。就是这样。。

#include <cstdlib>
#include <iostream>


using namespace std;


void simple()
{cout<<"It is a simple program.\n";}


int main()
{
    cout<<"Call function....\n";
    simple();
    (&simple)();
    (*&simple)();
    cout<<"address of function:\n";
    cout<<simple<<endl;
    cout<<&simple<<endl;
    cout<<*&simple<<endl;
    system("PAUSE");
    return 0;
}

还是会有错误不能编译

16 C:\Users\zh\Desktop\新建文件夹\happy.cpp [Warning] the address of `void simple()', will always evaluate as `true' 


原创粉丝点击