Thread: CLasses

  1. #1
    Registered User zergdeath1's Avatar
    Join Date
    Sep 2003


    Please im just practicing to get better at classes:

    #define PI 3.14
    class circle {
    int x;
    int radiuss (int r) {x=r;}
    int radius (void) {return  PI(x^2);}
    int main (){
    circle one;
    one.radiuss (2);
    return 0;
    Stolen Quote: Buttered Toast always lands butter side down and cats always land on their feet, what happens when you strap buttered Toast to the back of a cat?
    My Quote: Practice Makes Perfect Nobodys Perfect Why Practice?

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Seattle, WA
    So what is your question? I assume you will have a problem with x^2 since the "^" operator is actually the XOR operator...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Give your member variables and functions more descriptive names.

    class circle 
    	int nRadius;
    	void SetRadius (int nRadius_) {nRadius=nRadius_; }
    	int GetArea (void) {return  PI*pow(nRadius,2); }
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 05:38 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM