what is variant member in c++?

前端 未结 3 833
囚心锁ツ
囚心锁ツ 2021-02-20 00:34

I am new to C++. I read very frequently from some sites that variant member?.

class School
{
  int x; -> data member. 
}

I know data member

3条回答
  •  遥遥无期
    2021-02-20 01:09

    The term variant is usually employed to identify a member that can hold a value of a set of different types. Similar to a union in the language, the term variant is usually reserved for types that allow the storage of the different options in a type safe way.

    You might want to read over the documentation of the boost variant library for one such example, and if that does not clear up the concept, drop a comment/create a question with your doubts.

    Boost Variant

提交回复
热议问题