Skip to main content
GameDev.net gamedev.net
🔒 Locked

derived class template D:

Started by _WeirdCat_ Oct 28, 2017 at 8:59 AM 3 replies 1.4k views
Original Post
_WeirdCat_
_WeirdCat_

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?

matt77hias
matt77hias

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.

🧙
ChaosEngine
ChaosEngine
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
Aressera
Aressera

You need a typedef:


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


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.