derived class template D:

Started by
3 comments, last by Aressera 6 years, 5 months ago

So i have a base class:


template <class pos_depth, class normal_depth, class vel_depth, class mass_depth, class world_depth, class time_depth>
class PComponent

 

Now i have a second class"


struct AComponent : public PComponent<float, float, float, float, float, float>

However this does not compile i am not even sure if i can do such thing like that: 

 

error: 

Description    Resource    Path    Location    Type
expected '{' before '<' token    vcl.h    /WiredNavalBattle/jni/Editor    line 129    C/C++ Problem
expected template-name before '<' token    vcl.h    /WiredNavalBattle/jni/Editor    line 129    C/C++ Problem
expected unqualified-id before '<' token    vcl.h    /WiredNavalBattle/jni/Editor    line 129    C/C++ Problem
make.exe: *** [obj/local/armeabi-v7a/objs-debug/game/constvars2.o] Error 1    WiredNavalBattle             C/C++ Problem

Any thoughts?

 

Ah i forgot to include the header file, however i have another problem since in second class i want to call PComponent constructor it doesnt allow me to do that i could eaisly make a void in PComponent class which contains constructor code, and call it from AComponent (second class) but maybe theres another way?

Advertisement

The title of this topic is confusing (at least for me), especially with regard to the content and tag. I thought it was about the programming language D.

🧙

11 hours ago, WiredCat said:

in second class i want to call PComponent constructor it doesnt allow me to do that

Why not? Post the error message and show us the PComponent constructor and the where you’re trying to call it. 

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

You need a typedef:


class AComponent : PComponent<...>
{
  public:
  	typedef PComponent<...> Base;
 	AComponent() : Base(...) {}
};

 

This topic is closed to new replies.

Advertisement