FAQ Classes?? (C++)

This is a discussion on FAQ Classes?? (C++) within the FAQ Board forums, part of the General Programming Boards category; I need some help creating a circle class. It needs two methods to display the parameters and scaling,and it needs ...

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

    Question Classes??

    I need some help creating a circle class. It needs two methods to display the parameters and scaling,and it needs to print to the screen what the position is and the radius. Thanx for any help. I am really struggling with classes for some reason!

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Use the public identifier before you declare your methods and a private scope identifier before you declare the data members of the class. Give it a try.

  3. #3
    Registered User Engineer's Avatar
    Join Date
    Oct 2001
    Posts
    125
    You will need to create a class with private members such as position (x, y) and radius, and public methods according to your needs. Don't forget about constructor(s) and desctructor.

    Hope this helped.
    1 rule of the Samurai Code: if you have nothing to say, don't say anything at all!

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,641
    Think of a class as a special kind of struct. Nothing more. Then just realize that now you can not only have a structure which can hold data, but one that can "hold" functions, create itself, destroy itself, initialize itself(automatically set it's members to zero, sets strings to desired preset values[maybe char *name = "None Yet";]), morph itself according to the arguments it recieves ( even the Types! ), change the meanings of operaters such as "=" applied to it, and of course, who can hide or show it's data to other classes, etc.,etc, etc.

    But you have to try doing all this yourself! For a class is only worth what it's programmed to do! You could in fact start small, and write it precicely like a struct. Slowly build on it till it becomes more useful and modualer. Eventually, you will get the hang of it, but don't just ask someone to do it for you. Try it and see for yourself!
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

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. Wiki FAQ
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 192
    Last Post: 04-29-2008, 01:17 PM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  5. FAQ Check/Lock
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-15-2002, 11:21 AM

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