I keep getting the error error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'overloaded-function'. What do I need to do to fix this?
Hopefully what I say makes sense. So, on visual studios I have 3 source cpp files. They are ConsoleApplication2.cpp, stdafx.cpp, and circle.cpp. The one I just posted is circle.cpp. Whenever I compile circle.cpp on visual studios, it says this:
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug Win32 ------
1> circle.cpp
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(35): error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion)
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(498): could be 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(std::basic_streambuf<char,std::char_traits<char>> *)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(478): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(const void *)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(458): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(long double)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(438): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(double)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(418): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(float)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(397): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(377): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(__int64)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(356): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(unsigned long)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(336): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(long)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(316): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(unsigned int)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(291): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(int)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(271): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(unsigned short)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(237): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(short)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(217): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(std::_Bool)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(210): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(203): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(std::basic_ios<char,std::char_traits<char>> &(__cdecl *)(std::basic_ios<char,std::char_traits<char>> &))'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(197): or 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(std::basic_ostream<char,std::char_traits<char>> &(__cdecl *)(std::basic_ostream<char,std::char_traits<char>> &))'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(1026): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const std::error_code &)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(978): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,unsigned char)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(971): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const unsigned char *)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(964): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,signed char)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(957): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const signed char *)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(831): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(784): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const char *)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(746): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(699): or 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const char *)'
1> while trying to match the argument list '(std::basic_ostream<char,std::char_traits<char>>, overloaded-function)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
When I build the program it says, something pops up saying "this project is out of date ConsoleApplication2 - Debug Win32". And when I click on "yes" to build it, it says unable to start program, the system cannot find the file specified".
Thank You MiiNiPaa. That fixed a lot of things, but now I am getting this:
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug Win32 ------
1> circle.cpp
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(8): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(10): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(10): error C2144: syntax error : 'double' should be preceded by ';'
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(28): error C3874: return type of 'main' should be 'int' instead of 'double'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I tried changing my main function data type to double, but that didn't work.
#include "stdafx.h" // Precompiled header
#include "iostream" // Input and output stream
#include <cmath>
using namespace std; // Meaning you don't have to put std:: before cout <<;.
double calcArea();
double calcDiameter();
double calcCircumference();
pi = 3.14
double calcArea(double radius) {
double area;
area = pi * pow(radius, 2);
return area;
}
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug Win32 ------
1> circle.cpp
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(8): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(10): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>c:\users\jas\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\circle.cpp(10): error C2144: syntax error : 'double' should be preceded by ';'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Use code button ( <> ) to properly format your code.
Problem is here: pi = 3.14
It looks like you are declaring a variable, but all variables should have a type, which you did not provide.
fix: constdouble pi = 3.14159265358;, or, if you are using C++11 like you should constexprdouble pi = 3.14159265358;
Thanks so much! It compiles great, but there is a output display on visual studios 2013. Like it appears, and then dissappears so fast that I cannot even see my executable display. Any suggestions?