Jump to content
  • Advertisement
KKTHXBYE

C++ derived class template D:

Recommended Posts

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?

Edited by WiredCat

Share this post


Link to post
Share on other sites
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.

Edited by matt77hias

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites

You need a typedef:

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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!