Re: Error C2679

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Ulrich,
Before I posted the question I did a bit of searching on the internet and I
came across a post saying that the <string> library wasn't included. I
included it in my project and get 5 errors instead of 3.

Errors with <string> included:

Error 1 error LNK2028: unresolved token (0A000355) "int __cdecl
CalculateBelowAverage(int const * const,float)"
(?CalculateBelowAverage@@$$FYAHQBHM@Z) referenced in function "int __cdecl
main(void)" (?main@@$$HYAHXZ) Arrays_p625.obj

Error 2 error LNK2028: unresolved token (0A000356) "int __cdecl
CalculateAboveAverage(int const * const,float)"
(?CalculateAboveAverage@@$$FYAHQBHM@Z) referenced in function "int __cdecl
main(void)" (?main@@$$HYAHXZ) Arrays_p625.obj

Error 3 error LNK2019: unresolved external symbol "int __cdecl
CalculateBelowAverage(int const * const,float)"
(?CalculateBelowAverage@@$$FYAHQBHM@Z) referenced in function "int __cdecl
main(void)" (?main@@$$HYAHXZ) Arrays_p625.obj

Error 4 error LNK2019: unresolved external symbol "int __cdecl
CalculateAboveAverage(int const * const,float)"
(?CalculateAboveAverage@@$$FYAHQBHM@Z) referenced in function "int __cdecl
main(void)" (?main@@$$HYAHXZ) Arrays_p625.obj

Error 5 fatal error LNK1120: 4 unresolved externals C:\Documents and
Settings\Mark McCumber\My Documents\Visual Studio 2005\Projects\Visual
C++\Arrays_p625\Debug\Arrays_p625.exe 1

If the first three errors are caused by <string> not being included, Why do
I get unresolved tokens and externals when the library is included? It
doesn't make logical sense from my purspective.
--
Mark


"Ulrich Eckhardt" wrote:

Mark wrote:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
[...]
string inFileName;
cin >> inFileName;
[..]
Error 1 error C2679: binary '>>' : no operator found which takes a
right-hand operand of type 'std::string' (or there is no acceptable
conversion)

This program come right out of my textbook, so it should work.

No.

The error acts like the <iostream> wasn’t included.

Nope, it acts as if <string> wasn't included. The operator>> overload for a
std::string is in <string> and not <iostream>. Actually, the standard only
requires that <iostream> declares the classes istream, ostream and the
objects cin, cout, cerr, clog plus their wide counterparts. It doesn't
actually require that it fully defines the class, a simple forward
declaration is enough, so you theoretically <iostream> and <ostream> in
order to write to std::cout. In this case, <ostream> is implicitly included
by <fstream> though.

BTW: two more advanced lessons for you:
1. Read in the filename "C:\Documents and Settings\yourname\foo.barre".
2. Read in a number and then read that many filenames.

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

.



Relevant Pages

  • Re: Update sheetname from cell, automatically
    ... Const sERROR As String = "Invalid worksheet name in cell " ... Dim sSheetName As String ... Set mySheet = Sheet2 ... ElseIf Not ) Is ...
    (microsoft.public.excel.programming)
  • Re: unit testing C++ code from perl
    ... void ReportAssert(char const* description, char const* filename, int const ... That's probably the complaint string for an error. ... Then we have a filename and lineNumber. ... void FormatToStream(MemoryOutStream& stream, char const* format, ValueType const& value) ...
    (comp.programming)
  • RE: Get Open File Name dialog. When user clicks cancel.
    ... strCustomFilter As String ... Const ahtOFN_OVERWRITEPROMPT = &H2 ... Optional varTitleForDialog As Variant) As Variant ... Dim strFilter As String ...
    (microsoft.public.office.developer.vba)
  • RE: API Open Dialog. What if user cancels
    ... strCustomFilter As String ... Const ahtOFN_OVERWRITEPROMPT = &H2 ... Optional varTitleForDialog As Variant) As Variant ... Dim strFilter As String ...
    (microsoft.public.access.formscoding)
  • API Open Dialog. What if user cancels
    ... strCustomFilter As String ... Const ahtOFN_OVERWRITEPROMPT = &H2 ... Optional varTitleForDialog As Variant) As Variant ... Dim strFilter As String ...
    (microsoft.public.access.formscoding)