2

Im actually analysing some cod and i found this

 Ptr<UniformRandomVariable> m_yMinVar;

i have some c experience but no c++, what i understand is that the line declare a pointer call m_yMinVar and it's "type" <UniformRandomVariable> where "UniformRandomVariable" must be a class in other cpp file but i really dnot know,

i would like to know exactly what's Ptr because my text editor reconizes it as a variable type

also "<>" i'm not sure thats that

and finaly if someone can share me a link where i can see operators and diferent kinds of declaring variables and coding types like " i++ = i+= i=i+1"

doodbye everybody and thank u all

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Julioatuesta
  • 47
  • 1
  • 4
  • 1
    `Ptr` is the name of a template that has been defined prior to its use. – Pete Becker Nov 17 '18 at 16:48
  • You have two different and unrelated questions, please post it as two different and separate questions. But note that the second will be voted as off-topic. Please read [the help pages](http://stackoverflow.com/help), especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). – Some programmer dude Nov 17 '18 at 16:48
  • 2
    It also seems like you could use [a good book or two to read](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list/388282#388282). – Some programmer dude Nov 17 '18 at 16:48

1 Answers1

2

Ptr<UniformRandomVariable> is an instantiation of a class template. Instances of class templates are classes. Classes are user defined types. Ptr<UniformRandomVariable> m_yMinVar; as a whole is declaration of a variable of type Ptr<UniformRandomVariable>.

Ptr is the name of the template. Given the name, it would be fairly safe to assume that it is some sort of a wrapper around a pointer. If the first template argument of Ptr is a type argument, then UniformRandomVariable is the name of some type. It may be a class, or a typedef. If the first template argument of Ptr is a non-type argument, then UniformRandomVariable is some constant value.

Ptr must be defined within the same translation unit (prior to the instantiation). UniformRandomVariable must be at least declared in the same translation unit where it is used in the instantiation, and depending on the definition of the Ptr template, UniformRandomVariable may also need to be defined.

eerorika
  • 232,697
  • 12
  • 197
  • 326