Class definition in headers file .h

Hi
Can someone explain what does class defintion in headers file means. I googled a lot things and read serveal books
Many thanks
Bill Thompson
closed account (1vRz3TCk)
Try: http://www.cplusplus.com/articles/Gw6AC542/
1
2
3
4
5
class CRectangle {
    int x, y;
  public:
    void set_values (int a,int b);
};


This is an example of a class definition, that you can define in a header file. Do notice that we currently have no implentation of set_values. So therefore we make a .cpp file and put this in there:

1
2
3
4
5
6
#include "HeaderfileName.h"

void CRectangle::set_values (int a, int b) {
  x = a;
  y = b;
}


The reason for doing this is that your code gets a lot more organized, especially when you have hundreds or thousands of lines of code.
Last edited on
Thanks everyone, it seems much more clearer to me now than it did serveal hours ago
Topic archived. No new replies allowed.