Skip to main content
2 of 2
added 1009 characters in body
Jerry Coffin
  • 44.9k
  • 5
  • 92
  • 165

The header is used so that other modules ( .cc files) can use the function. For example:

foo.h:

int foo(); 

foo.cpp:

int foo() { // ... } 

bar.cpp:

// Get the declaration of foo() #include "foo.h" // Now we can write code that calls foo(): int bar() { foo(); } 

It's not immediately clear what an "abstract function" necessarily means. It could be used to refer to a function that implements some abstraction (which nearly all functions should). Another possibility I can see is possibly a reference to an abstract base class, which is a base class that contains a pure virtual function.

class foo { public: virtual void bar() = 0; // the "=0" means "pure virtual function" }; 

Containing a pure virtual function means we can't instantiate foo--that is, we can't actually create any object of type foo. To create an object, we need to derive another class from foo, and override bar in that derived class:

class baz : public foo { public: void bar() { // ... } }; 

A virtual member function allows a derived class to override the base class' behavior. A pure virtual requires that the derived class override the base class' behavior to be able to create objects of that class. That, however, is an abstract base class, not an abstract function.

Jerry Coffin
  • 44.9k
  • 5
  • 92
  • 165