简体   繁体   中英

In c++ what does Ptr<> a stands for?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM