1

I have a file GetL.hxx

#ifndef GetL_included
#define GetL_included
#include <iostream>
using namespace std;
class GetL
{
 public:
    virtual int getWidth();
};
#endif //GetL_include

Here the class GetL contains only one virtual function. what should i put in source file i.e. in GetL.cxx

Rog Matthews
  • 3,147
  • 16
  • 37
  • 56

1 Answers1

3
#include "GetL.hxx"

int GetL::getWidth() {
  // your code goes here
}

By the way, having using namespace std; in a header file is not a good practice.

Community
  • 1
  • 1
NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • how can i `#include ` without having `using namespace std`?? – Rog Matthews Feb 22 '12 at 09:24
  • i want to create a virtual method so that GetL class can be inherited and getWidth method overridden. If i give implementation like that it will defeat the reason because of which i created it.. – Rog Matthews Feb 22 '12 at 09:26
  • If you `#include ` without `using namespace std`, you refer to the contents of iostream as within the std namespace. For example, you use `std::cout`, not just `cout`. This avoids polluting the global namespace. Nonetheless, you aren't using anything from the iostream header file so you don't need to include it. – Joseph Mansfield Feb 22 '12 at 09:42