Thread: Classes using phone numbers

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Question Classes using phone numbers

    Greetings,

    What is wrong with this? I am having problems understanding classes, man. I need a push in the right direction, plz

    Code:
    /*	Specs:
    *	an area code, an exchange, a local number, and a long-distance indicator (true or false).
    *	Design and build a PhoneNumber class that models a phone number, providing operations 
    *	to construct, input, output extract each of the data members of a PhoneNumber object, 
    *	and indicate whether or not the number is long-distance. The input operation should 
    *	read a local or long-distance number and set the long-distance indicator accordingly. 
    *	The output operation should display a local number differently from the way it 
    *	displays a long-distance number (e.g., 555-1234 vs. (616) 555-1234). 
    */
    
    
    
    class PhoneNumber
    {
       public:
         phoneNo();	//declare constructor here
    	//declare functions to change and retrieve each of the private data members here
         void Print (ostream & out) const;	//declare function to get input here
         phNo_Print(cout);	//declare function to output phone number here
     
       private:
         //declare private data members here
         int areaCode;
         int exchange;
         int localNumber;
         bool longDistance;
    };
    
    void phoneNo()	//function definitions for each of the public member functions go here. 
    {
    	
    	return 0;
    }
    Last edited by correlcj; 11-13-2002 at 05:55 PM.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    What specifically is confusing you?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    this portion

    the whole public portion...what to place in it and I do declare it in the header file, correct?? My brain seems to be not working with this chapter of classes. Classes, AAAAAAAAAAAWWWWWWWaaarrrgh!!!
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    How would you solve this with C? Try that first, making sure to be "object oriented" about it. Do the easy stuff first too, and test that first before moving on. Then write it using classes that encapsulate the C functions. Finally, write it to spec. Just an idea
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with Rational Numbers (C++)
    By cloudjc in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2008, 04:03 PM
  2. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM
  3. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  4. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  5. Replies: 4
    Last Post: 03-03-2003, 03:52 PM