AndroidNewbie February 2016

Class instantiations in cpp

If I have a header class in C++, what do the class ColorData and class PixelBuffer instantiations do? Does it mean the header file recognizes these other classes, are parents of the header class, or something else? The class i'm currently in is BrushWorkApp.h

#ifndef BRUSHWORKAPP_H
#define BRUSHWORKAPP_H
#include "BaseGfxApp.h"
class ColorData;
class PixelBuffer;

class BrushWorkApp : public BaseGfxApp {//more stuff in here}

Answers


Anedar February 2016

This is called a forward-declaration and is pretty similar to declarations of functions without a body:

Basically it tells the Compiler "Those two symbols refer to classes." Without further specifying how the classes look. Due to this, you are limited in using them, e.g. you can use them as parameters, pointers or template arguments but you can't use any members of the classes.

Post Status

Asked in February 2016
Viewed 2,728 times
Voted 7
Answered 1 times

Search




Leave an answer