CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2003
    Location
    China xi'an
    Posts
    7

    cout.put(65) error. why?

    VC consloe
    cout.put(65)//65 is the ASCII code of 'A'
    error C2668: 'put' : ambiguous call to overloaded function
    why?

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725
    Are you using

    Code:
    #include <iostream.h>
    if so, that is non-standard ... use the standard

    Code:
    #include <iostream>

  3. #3
    Join Date
    Apr 2003
    Location
    China xi'an
    Posts
    7
    Originally posted by Philip Nicoletti
    Are you using

    Code:
    #include <iostream.h>
    if so, that is non-standard ... use the standard

    Code:
    #include <iostream>
    thanks much! but when i use
    #include <iostream>
    cout became an undeclared identifier!
    error C2065: 'cout' : undeclared identifier

  4. #4
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725
    the stream functions reside in namespace std,
    so you need something like this:

    Code:
    #include <iostream>
    
    using namespace std;  // add this line
    
    int main()
    {
        cout.put(65);
    
        return 0;
    }
    or you can qualify cout as follows :

    Code:
    #include <iostream>
    
    int main()
    {
    
        std::cout.put(65);
    
        return 0;
    }
    If you do a search on Andreas Masur posts, he has a
    good exaplanation on namespaces

  5. #5
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

  6. #6
    Join Date
    Apr 2003
    Location
    China xi'an
    Posts
    7

    you are really kind

    thanks again! you have help me resolve the problem throughly
    btw:
    West Virginia an beautiful place I have known from
    <take me home country roads > of John denver

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured