Thread: Creating an INF data type.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2014
    Posts
    143

    Creating an INF data type.

    I want to create a new data type called an inf_t. It's basically infinity (which for C++ is 1.7e+308). The only reason I want this is because I want to overload the cout << operation to print out INF/inf. Should I do this in a struct?

    Code:
    struct inf_t {
    
    
    private:	
    	double inf = 1.7e+308;
    };
    
    
    std::ostream& operator << (std::ostream &stream, inf_t inf) {
    	
    	stream << "INF";
    
    
    	return stream;
    }
    Last edited by cmajor28; 01-21-2015 at 10:37 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating a list pointer of parent type from base type...
    By Adamkromm in forum C++ Programming
    Replies: 14
    Last Post: 04-14-2012, 02:07 PM
  2. Replies: 2
    Last Post: 05-14-2011, 09:26 PM
  3. store string data as a short or other data type
    By robin2aj in forum C Programming
    Replies: 5
    Last Post: 04-07-2010, 11:02 AM
  4. Creating a map with a new object type
    By blacknail in forum C++ Programming
    Replies: 6
    Last Post: 11-24-2008, 10:16 AM
  5. Creating object of type HWND from a dll
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 03-13-2002, 12:40 AM