C++ Visual Studios 2013


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?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  #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();
#define PI 3.14159

double calcArea(double radius) {
	double area;
	area = PI * pow(radius, 2);
	return area;
}

double calcDiameter(double radius) {
	double diameter;
	diameter = radius * 2;
	return diameter;
}

double calcCircumference(double radius) {
	double circumference;
	circumference = 2 * PI * (radius * 2);
	return circumference;
}

int main() {
	
	cout << "Radius sizes for Area" << endl;
	cout << calcArea(10) << endl;
	cout << calcArea(12.5) << endl;
	cout << calcArea(1.03) << endl;

	cout << "Radius sizes for Diameter" << end;
	cout << calcDiameter(10) << endl;
	cout << calcDiameter(12.5) << endl;
	cout << calcDiameter(1.03) << endl;

	cout << "Radius sizes for Circumference" << endl;
	cout << calcCircumference(10) << endl;
	cout << calcCircumference(12.5) << endl;
	cout << calcCircumference(1.03) << endl;

	return 0;

}Put the code you need help with here.
is this your whole code?
it works to me

// Meaning you don't have to put std::  before cout <<;

<< isnt part of std namespace
Last edited on
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".
cout << "Radius sizes for Diameter" << end;
FInd a typo.
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.
I tried changing my main function data type to double, but that didn't work.
Of course this would not work as Standard clearly says: "main() shall return int"

It looks like one of your later changes in code broke something: code you posted should work after correcting typo. Mind posting your current code?
#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;
}

double calcDiameter(double radius) {
double diameter;
diameter = radius * 2;
return diameter;
}

double calcCircumference(double radius) {
double circumference;
circumference = 2 * pi * (radius * 2);
return circumference;
}

int main() {

cout << "Radius sizes for Area" << endl;
cout << calcArea(10) << endl;
cout << calcArea(12.5) << endl;
cout << calcArea(1.03) << endl;

cout << "Radius sizes for Diameter" << endl;
cout << calcDiameter(10) << endl;
cout << calcDiameter(12.5) << endl;
cout << calcDiameter(1.03) << endl;

cout << "Radius sizes for Circumference" << endl;
cout << calcCircumference(10) << endl;
cout << calcCircumference(12.5) << endl;
cout << calcCircumference(1.03) << endl;

return 0;

}

These are the errors:

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 ==========
Everything is indented properly by the way.
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: const double pi = 3.14159265358;, or, if you are using C++11 like you should constexpr double 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?
Thank You!
Another way: press Ctrl+F5 instead of F5 to compile and run.
Gotcha!
Topic archived. No new replies allowed.