Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtual not permitted on data declarations

Tags:

c++

templates

When trying to declare an abstract class, I don't seem to be able to have templated functions. Why is this, and how do I deal with it? Here is my example header file.

// Foo.h
#include "Bar.h"
#include "Baz.h"
class Foo
{
public:
    Foo();
    virtual Bar<Baz> *getBaz() const = 0;
         //snip
};

Other compiler error from the same line includes

syntax error: missing ';' before '<'

like image 388
vapo Avatar asked Sep 01 '26 11:09

vapo


1 Answers

I looks like it does not recognize Bar as a type.

Check your two header files and make sure:

1) That it is defined
2) The include guards are correct and it is not hidden.

like image 179
Martin York Avatar answered Sep 03 '26 23:09

Martin York



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!