Questions tagged [template-classes]

184 questions
0
votes
0 answers

C++ Class Templates unable to match function definition to an existing declaration

I have the following in a header file. A template class with many functions. #pragma once #include using namespace std; template class Vector3Generic { public: T x; T y; T z; Vector3Generic(); …
Aaron Azhari
  • 987
  • 1
  • 10
  • 24
0
votes
1 answer

C++ error declaring std::pair inside template class

I want to avoid using the std::pair() constructor or std::make_pair() functions while inserting into a map. I also want to know the success status of the insert operation, so I cannot use operator[]. I tried the following code but it produces a…
Dinesh
  • 1,825
  • 5
  • 31
  • 40
0
votes
3 answers

testing "Try and Catch"

In this program, I am using template class, I have a header file and this is my main file. I am having trouble displaying the (".....") IndexOutOfBounds and displaying it on the screen. #include "XArray.h" #include #include…
bonafide
  • 368
  • 4
  • 25
0
votes
0 answers

C++ template class that uses vector

In a little project of mine I have situation like this: // Header file template ; class AClass { public: virtual void doSomething() const; private: std::vector *v; }; // separate cpp file template void…
Glenn
  • 140
  • 1
  • 7
0
votes
1 answer

Template class non-templated method argument

I have a class which uses templates. It is something like this: template class a { public: a(T arg); a func(a arg); // This seems to work, but... a func(a arg); // ...should I be doing this instead? private: T…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
0
votes
1 answer

issues when deriving a non-template class from a template class in C++

I'm trying to inherit a non-template class from a template class that specified witch type I need My code is like this: the header file for base class(updated): //base.hpp template class Base { public: Base(T a,int b) : …
ARF
  • 72
  • 7
0
votes
0 answers

Issue creating a template class for the first time

I have been reading up on creating template classes and I think I have it.. well, apart from one annoying bug I can't figure! this is what I have so far: template class CStateMachine { public: // Constructor CStateMachine(QByteArray…
code_fodder
  • 15,263
  • 17
  • 90
  • 167
0
votes
2 answers

c++ "no appropriate default constructor available" error using template class data member

I made a template class Grid(where i said in the header file that the default for T is float), i quoted a part of the source file: #include"Grid.h" template Grid::Grid(unsigned int rows=1, unsigned int…
Wouter
  • 113
  • 1
  • 7
0
votes
1 answer

Export Template Class from C++ library to VB.NET and C#

I've the following problem: I've created a DLL in C++ with a template class definition like this: template class myClass { public: //! Constructor myClass(int size = 10); //! Destructor ~myClass(); …
Dersu
  • 319
  • 1
  • 7
0
votes
1 answer

Spring AOP Pointcut for a template class not working

I have the following class as my point cut public class GenricExceptionMapper implements ExceptionMapper { Logger logger = Logger.getLogger(GenricExceptionMapper.class); public Response toResponse(Exception exception) { …
CodePredator
  • 415
  • 2
  • 6
  • 14
0
votes
4 answers

Another Way to do Templates in C++?

I was just messing about, when I discovered this pre-processor dependent way of creating a template class: #include #include // Is this a valid template class? #define TEMPLATE_CLASS(T)\ class TemplateClass_ ##…
ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
-1
votes
1 answer

Template Class in C++ to Implement a Stack

I'm having compilation errors & need help on how to write my methods. #include #include #include #include using namespace std; template class Stack{ public: Stack(); …
-1
votes
1 answer

friend function is not a friend of all template instances?

In the following example I try to access the private member function subscribe() from a templated class type from within its friend function. However it appears that the friend function is only befriended in one instantiation of the class and not…
glades
  • 3,778
  • 1
  • 12
  • 34
-1
votes
1 answer

SIGSEGV error in copy constructor of template class

I am trying to test/debug a simple c++ code with template class and copy constructor. I define a vector class (user defined not STL) with 2 constructors one for initialization of vector elements and another for assigning values from an array. First…
-1
votes
1 answer

error c2953: error while making double link list

i have following code which is showing error in "Node.cpp" file #include "stdafx.h" #include using namespace std; template//think error is here class Node { private: X data; Node *prev,*next; public: …