(Rookie) Creating a void Function error

This is a discussion on (Rookie) Creating a void Function error within the C++ Programming forums, part of the General Programming Boards category; So im using Dev C++, and im reading a book about C++, im triying to create a void function = ...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    4

    Unhappy (Rookie) Creating a void Function error

    So im using Dev C++, and im reading a book about C++, im triying to create a void function = no return function.
    But when I try to compile it a get several errors such as

    variable or field `PrintName' declared void

    `string' was not declared in this scope

    Con you guys help me please?
    Heres the screen cap
    http://img855.imageshack.us/img855/9549/asdasdasdss.jpg
    Attached Images Attached Images  
    Last edited by Joel Hernández; 12-17-2012 at 08:22 PM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,976
    You probably should move that using directive to just before that function definition. Also, note that you are missing a semi-colon and closing brace for your main function.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    4
    Allright so i Tried this way
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <string>
    using namespace std;
    void PrintName(string frist,string last)
    {
         string fullname = first + " " + last;
         cout << fullname << endl;
         }
    
    
     
     
    int main(int argc, char *argv[])
    {
        PrintName("Thomas","Jefferson")
    }
        system("PAUSE");
        return EXIT_SUCCESS;
    and still have multiple errors
    Heres the link for BIG img
    http://img855.imageshack.us/img855/9549/asdasdasdss.jpg
    Attached Images Attached Images  
    Last edited by Joel Hernández; 12-17-2012 at 08:15 PM.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,976
    Post the error messages, not a screen shot. What do you think the error messages mean?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Dec 2012
    Posts
    4
    Quote Originally Posted by laserlight View Post
    Post the error messages, not a screen shot. What do you think the error messages mean?
    In the screenshot you can see the multiple errors listed... , one of them says that "first" its not declared , but I allready did, I declared string first, string last ...

  6. #6
    Registered User
    Join Date
    Dec 2012
    Posts
    4
    Found the error, typing mistake. LOL

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,976
    Quote Originally Posted by Joel Hernández
    In the screenshot you can see the multiple errors listed
    Certainly, but the idea here is for you to get a closer look at the error messages when copying them from your IDE's window and then pasting them here, nicely formatted with line numbers. Furthermore, it is easier to read as text than as an image.

    Quote Originally Posted by Joel Hernández
    one of them says that "first" its not declared , but I allready did, I declared string first, string last ...
    Quote Originally Posted by Joel Hernández
    Found the error, typing mistake. LOL
    Good. What about the others?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,266
    Quote Originally Posted by Joel Hernández View Post
    Found the error, typing mistake. LOL
    What, you mean I'm too late to say "FRIST"?!

    The last two lines of code need to be inside the main function. At the moment they are floating off into space from no-mans-land.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: invalid conversion from 'const void*' to 'void*'
    By Wahidin Wahid in forum C++ Programming
    Replies: 10
    Last Post: 04-17-2012, 02:17 AM
  2. error invalid conversion from ‘const void*’ to ‘void*’
    By Wahidin Wahid in forum C Programming
    Replies: 3
    Last Post: 03-27-2012, 08:18 PM
  3. an uber-simple array/function question for a c rookie!
    By variable83 in forum C Programming
    Replies: 13
    Last Post: 12-06-2009, 12:24 PM
  4. void function that builds but error when trying to run
    By romeoz in forum C++ Programming
    Replies: 7
    Last Post: 07-18-2003, 06:52 PM
  5. Replies: 4
    Last Post: 01-02-2002, 09:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21