J
J
jackroll2014-10-20 15:52:04
C++ / C#
jackroll, 2014-10-20 15:52:04

Can't instantiate a class and access its methods?

in header.h

#ifndef _HEADER_H
#define _HEADER_H

template<typename T>
class mytype
{
public:
  mytype(void)
  {
    myvar = 0;
  };
  mytype(const T& var)
  {
    myvar = var;
  }
  mytype(const mytype& var)
  {
                this->myvar = var->myvar;
  };
  mytype operator=(const mytype& var)
  {
                 this->mytype(var);
  };
  const T operator*(const mytype& var);
  const T operator/(const mytype& var);
  const T operator+(const mytype& var);
  const T operator%(const mytype& var);
private:
  T myvar;
};


#endif

I can not create an instance of the class and access its methods. What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tdi, 2014-10-20
@jackroll

Well, first of all, I guess

mytype(const mytype& var)
  {
    this->mytype(var.myvar);
  };

And that doesn't work, does it
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question