Thread: compile error

  1. #1
    Registered User
    Join Date
    Dec 2003

    compile error

    can a fucntion return multiple values ? probabily use of structure may help to return more than one values.

    i wrote a code, its giving compile error.

    using namespace std;
    struct test
    int flag;
    int x;
    char y;
    struct func(); // prototype
    int main()
    struct test d  = func();
    if (d.flag==1)  { cout<<"char returned"; cout<<d.y;}
    struct func()
    struct test c;
    if(ch<127) // checking whetehr ch is a char
       c.y= ch;
       return c;
    c.x = 100;
    return c;

    question 1. > why there is error ?

    question 2.> how can i fix those error?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > struct func(); // prototype
    You want the name of the struct as well
    struct test func(); // prototype

    Or since this is c++, you can simply do
    test func(); // prototype

    Don't forget to fix the actual function as well
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM