Thread: ftn that returns type

  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
    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, 08:18 PM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  3. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06: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, 01:27 PM