M
M
Monstr19862018-09-05 18:32:04
C++ / C#
Monstr1986, 2018-09-05 18:32:04

When inheriting a class template, I get error c2760 in the constructor definition line, what is the error?

There are two class templates, the first is:
TypeSize.h
Code:
#pragma once
Code:

template <class T1>
class TypeSize
{
public:
  TypeSize(T1 value);
  ~TypeSize();
};

The second inherits from the first:
TypeInfo.h
Код:
#pragma once

template <class T1>
class TypeInfo : public TypeSize<T1>
{
public:
  TypeInfo(T1 value) : TypeSize<T1>(value); // тут получаю C2760 синтаксическая ошибка: ожидался токен "<Нет данных>", а не "<Нет данных>"
  ~TypeInfo();
};

Tell me what could be the problem.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-09-05
@Monstr1986

TypeInfo(T1 value) : TypeSize<T1>(value);

If this is an ad, then : TypeSize<T1>(value)there is no need. If this is a definition, then the body of the constructor should go
instead :;
TypeInfo(T1 value) : TypeSize<T1>(value)
{
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question