c++ - Reference to ' ' is ambiguous -


i sorry don't know why algorithm not working. error @ compiling : "reference 'function' ambiguous " , on y = function() line, calling function

#include <iostream> #include <stdlib.h> #include <stdio.h> #include <math.h> #define pi 3.141 float function(int g, int m, int s, float z) {     using namespace std;     z = (g + m/60.0 + s/3600.0)*pi/180.0;     return z; } int main() {      using namespace std;      float y;     int g,m,s;      cout << "g = ";     cin >> g;     cout <<"m = ";     cin >> m;     cout<<"s= ";     cin >>s;      y = function();     cout << "y= " << y << endl;     //cout<< (g + m/60.0 + s/3600.0)*pi/180.0 << endl;     return 0; } 

vers2 - updated:

#include <iostream> #include <stdlib.h> #include <stdio.h> #include <math.h> #define pi 3.141 float function(int g, int m, int s) {     //using namespace std;     float z = (g + m/60.0 + s/3600.0)*pi/180.0;     //std::cout << z <<std::endl;     return z; } int main() {     // using namespace std;      float y;     int g,m,s;      std::cout << "g = ";     std::cin >> g;     std::cout <<"m = ";     std::cin >> m;     std::cout<<"s= ";     std::cin >>s;      function();   //  std::cout << "y= " << y << std::endl;     //cout<< (g + m/60.0 + s/3600.0)*pi/180.0 << endl;     return 0; } 

there member function in std , inserted namespace. avoid using using namespace std;; can import need way:

using std::cout; using std::cin; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -