Classes

This is a discussion on Classes within the C++ Programming forums, part of the General Programming Boards category; if anyone can help me i am unsure of what to do after this point basically i have created the ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    24

    Classes

    if anyone can help me i am unsure of what to do after this point
    basically i have created the header file
    it has all the get and set things
    and i have the structure for the .cpp file but i am unsure of what to put into the .cpp

    Code:
    #include "StdAfx.h"
    #include "Circle.h"
    
    float Circle::getradius()
    {
    // what do I put in here ???
    }
    void Circle::setradius(float)
    {
    // what do I put in here ???
    }
    thanks for your time
    Last edited by laserlight; 03-30-2008 at 07:47 AM. Reason: Explanation is not code.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,440
    Moved to C++ programming forum.

    You may want to show us Circle.h.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    24
    this is circle.h i am just looking for an example of what i should do really for the .cpp file
    Code:
    class Circle
    {
    private: 
    
    	float raduis
    
    
    public: 
    
    	void setraduis(float);
    	float getraduis(void);
    
    	Circle(void);
    	~Circle(void);
    
    }
    thanks again

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,440
    Note that raduis should be radius, and you are missing two terminating semi-colons in your header file.

    Anyway, you just need to assign to the member variable in setradius() and return it in getradius().
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    24
    thank you for that much apricaited but I know i need one semi colon on the radius but where is the second one to go it alludes me lol

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,440
    thank you for that much apricaited but I know i need one semi colon on the radius but where is the second one to go it alludes me lol
    At the end of the class definition:
    Code:
    class Circle
    {
    // ...
    }; // <--
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    24
    thank you so much you have helped me alot !!!!

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. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 04:38 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

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