Questions tagged [class-template]

Anything related to C++ class templates, i.e. classes whose definition depends on some parameter according to templates definition rules.

Anything related to C++ class templates, i.e. classes whose definition depends on some parameter according to templates definition rules.

See:

243 questions
0
votes
2 answers

I created a List Container class in C++ and it's not working as expected

So first I created a struct to contain the following: template struct ListNode { unsigned int id; T data; ListNode *next_left; ListNode *next_right; }; And a class with the following: template class List…
Fergarram
  • 23
  • 1
  • 5
0
votes
0 answers

Template class fails to register constructor, Why?

In a C++ Program, attempting to use templates in a class I'm developing results in my compiler not registering the class constructors declared in the source. If I remove the template it compile fine, but other that that in the last hour I've made no…
Vera F W C
  • 208
  • 3
  • 11
0
votes
1 answer

Very Confused on Template INL File

Okay, I thought I had implementation files for template classes figured out, but apparently not... I have the following files in a VS 2013 C++ solution: Main.cpp #include "StateManager.h" #include "State.h" enum class Derp { Herp, Lerp, …
Rabadash8820
  • 2,328
  • 3
  • 27
  • 49
0
votes
2 answers

c++ parameter pack specification in constructor rather than template

Unlike function declarations with parameter packs, I've found that classes require the type for each argument in the angle brackets... Component temp(40, 5); ...which seems redundant. Here's how I defined…
0
votes
1 answer

How to deal with ambiguities in same template multiple inheritance?

I am working on my own WinAPI wrapper library, which takes care of everything related to GUI. I've kind of ported solutions I saw on Android platform (Views, measure/layout/draw passes, "inflating" UI from XML). Now: I didn't want to repeat myself…
Chris Miemiec
  • 755
  • 1
  • 9
  • 19
0
votes
1 answer

Scope resolution instead of . operator for template class argument

below given code compiles successfuly: template class C; class X { public: int n; }; int main() { C* c; //Here return 1; } How the Scope resolution operator works here rather than the…
Sreeraj Chundayil
  • 5,548
  • 3
  • 29
  • 68
0
votes
1 answer

Can not output a string from a class template

I have been trying to get my class template to print out a string for me. However I am getting a error C679: No operator found which takes a right hand operand of type std:: string. I have tried various way to make this error disappear. #include…
Erick
  • 19
  • 1
  • 7
0
votes
1 answer

template class operators "unresolved externals"

In my class : #ifndef __MYVECTOR_CLASS__ #define __MYVECTOR_CLASS__ template class MyVector{ .... MyVector& operator=(const MyVector& source); //works friend MyVector operator+(MyVector lhs, const MyVector
Cirvis
  • 382
  • 1
  • 4
  • 15
0
votes
2 answers

template functions and classes

I'm really confused by templates. If I have a template class and I pass it as an argument to a function, consider the following : template class Class { }; So I want to make a function that takes Class as an argument, so why the…
Tugal.44
  • 153
  • 4
  • 13
0
votes
2 answers

C++ Class Template Issue

I get an error in my program saying "Unresolved External symbol", i tried everything i know but couldn't solve it. I started getting this error after i used class template. Here is FileHandler Class Header :- #include #include…
Troller
  • 1,108
  • 8
  • 29
  • 47
0
votes
2 answers

Class template interaction

I am actually fairly certain the answer to my problem can be found in one of the previously created threads. In particular, Where and why do I have to put the "template" and "typename" keywords? which has a great explanation on template/typename…
0
votes
1 answer

c++ inherit from a template struct

I have two class to define some operations and keep a record of matrix rows and cols. One for host, another for device. struct device_matrix { device_vector data; int row; int col; // constructors device_matrix()…
user2684645
  • 501
  • 1
  • 7
  • 15
0
votes
1 answer

c++: C2783 error instanting class template

Excuse me in advance for my bad english..i'm developing my own STL and i have some problem using template. This is the main structure of the my List class: List.h template class List{ public: //public methods …
Andrea
  • 13
  • 4
0
votes
1 answer

Can I specify the type of the class template when inherits it into a child class?

Say, I have a parent class template. And want to build several child class upon it. Each child class are typename specific. So can I specify the typename they use when inherit their parent class template? example of the class definition: template…
Chong
  • 933
  • 2
  • 10
  • 28
0
votes
2 answers

why define lt when operator< exists?

A piece of code for vector operations contains these class template definitions: template class lt { public: static int compare(T a, T b) { return(a < b); } }; template class gt { public: static int compare(T…
alle_meije
  • 2,424
  • 1
  • 19
  • 40