N
Nuno Barros
Hello,
I am writting a c++ code to crete a kind of a table in memory.
Each table has an container of columns, which can be of any type.
To do this i created a virtual class Column which has some daugther
classes like ColumnInt, ColumnFLoat, etc etc.
The problemis that i must access the data in the columns by using an
Object (pointer) of the type Column.
In this class i need to create a method to get values from the column.
The problem is that for each type of column the return type will be
different.
I tried using a template like
template <typename T>
virtual T getValue(int index)
but this is not a good idea since everytime that i need to use an
object Column i need to specify a type : Column<int> for example.
Is there some way to do this without an template?
Using a virtual class how can i implement a method that has different
return types depending on the Daughter class?
Thanks in advance,
Nuno
I am writting a c++ code to crete a kind of a table in memory.
Each table has an container of columns, which can be of any type.
To do this i created a virtual class Column which has some daugther
classes like ColumnInt, ColumnFLoat, etc etc.
The problemis that i must access the data in the columns by using an
Object (pointer) of the type Column.
In this class i need to create a method to get values from the column.
The problem is that for each type of column the return type will be
different.
I tried using a template like
template <typename T>
virtual T getValue(int index)
but this is not a good idea since everytime that i need to use an
object Column i need to specify a type : Column<int> for example.
Is there some way to do this without an template?
Using a virtual class how can i implement a method that has different
return types depending on the Daughter class?
Thanks in advance,
Nuno