ftn that returns type

This is a discussion on ftn that returns type within the C++ Programming forums, part of the General Programming Boards category; I am looking for a function that returns what a value is...if it's a digit or a char. Basically, here's ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    3

    ftn that returns type

    I am looking for a function that returns what a value is...if it's a digit or a char.
    Basically, here's what I'm trying to do:

    // class outline

    class mb
    {
    public: mb( int i );
    mb( char c );
    int getNum();
    char getCh();
    bool isNum();
    private: int num;
    char ch;
    bool isAnum;
    };

    Basically, I will create a new mb and assign a value. For ex in main:
    mb *p1 = new mb(23);
    mb *p2 = new mb('x');

    // now when retrieving value to use somewhere else, i will use
    // the bool ftn to tell me wether it's an int or not.
    bool b = p2 -> isNum();
    //etc.

    but, isdigit doesn't work for this. at least when i tried it with a very simple test program it didn't work.

    any ideas?
    any help would be greatly appreciated

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You could set isAnum in your constructor depending on which one is called.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  3. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 05:33 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

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