Click here to Skip to main content
15,909,332 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Stupid Menu Question Pin
Richard Andrew x641-Mar-09 13:22
professionalRichard Andrew x641-Mar-09 13:22 
GeneralRe: Stupid Menu Question Pin
Mats Selen2-Mar-09 1:40
Mats Selen2-Mar-09 1:40 
Questiontemplate and vector [modified] Pin
transoft1-Mar-09 7:24
transoft1-Mar-09 7:24 
AnswerRe: template and vector Pin
Code-o-mat1-Mar-09 7:59
Code-o-mat1-Mar-09 7:59 
GeneralRe: template and vector Pin
transoft1-Mar-09 8:14
transoft1-Mar-09 8:14 
GeneralRe: template and vector Pin
Code-o-mat1-Mar-09 8:18
Code-o-mat1-Mar-09 8:18 
GeneralRe: template and vector Pin
transoft1-Mar-09 8:22
transoft1-Mar-09 8:22 
GeneralRe: template and vector Pin
Code-o-mat1-Mar-09 8:43
Code-o-mat1-Mar-09 8:43 
Well, if the structure isn't too complex, you could simply use a union and some way to signal what type your struct is actually holding. Something like:
#define STRUCT_TYPE_FLOAT   1
#define STRUCT_TYPE_DOUBLE   2
#define STRUCT_TYPE_INT  3
...
struct Cell
{
public:
  short typeFlag;
  union {
    float   valFloat;
    double  valDouble;
    int     valInt;
    ...
  };
};
...
std::vector<Cell> my_vector; 
Cell cell_double;
cell_double.valDouble = 1.23;
cell_double.typeFlag  = STRUCT_TYPE_DOUBLE;
my_vector.push_back(cell_double);
Cell cell_int;
cell_int.valInt = 123;
cell_int.typeFlag = STRUCT_TYPE_INT;
my_vector.push_back(cell_int);
...

If it's a bit more complex than that then you should rather use pointers, something like this:
class CellBase
{
  virtual ~CellBase()
};
template<typename TType>
class Cell: public CellBase
{
  ...
};
std::vector<cellbase> my_vector;
my_vector.push_back(new Cell<int>(123));  //Don't forget to delete the Cells somewhere later...

These are far from complete implementations of anything, just "skeletons"...

> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <

GeneralRe: template and vector Pin
transoft1-Mar-09 8:45
transoft1-Mar-09 8:45 
GeneralRe: template and vector Pin
Code-o-mat1-Mar-09 9:08
Code-o-mat1-Mar-09 9:08 
GeneralRe: template and vector Pin
transoft1-Mar-09 9:50
transoft1-Mar-09 9:50 
GeneralRe: template and vector Pin
Stuart Dootson1-Mar-09 9:30
professionalStuart Dootson1-Mar-09 9:30 
QuestionCan a ellipsis (Variadic) function i.e Func(...) be exported from a DLL Pin
Ru_Coding1-Mar-09 4:06
Ru_Coding1-Mar-09 4:06 
AnswerRe: Can a ellipsis (Variadic) function i.e Func(...) be exported from a DLL Pin
Stuart Dootson1-Mar-09 4:50
professionalStuart Dootson1-Mar-09 4:50 
GeneralRe: Can a ellipsis (Variadic) function i.e Func(...) be exported from a DLL Pin
Ru_Coding2-Mar-09 1:04
Ru_Coding2-Mar-09 1:04 
Questionhow to convert image into binary using C++ Pin
naveen20_51-Mar-09 3:53
naveen20_51-Mar-09 3:53 
AnswerRe: how to convert image into binary using C++ Pin
Code-o-mat1-Mar-09 5:39
Code-o-mat1-Mar-09 5:39 
AnswerRe: how to convert image into binary using C++ Pin
Eytukan1-Mar-09 6:11
Eytukan1-Mar-09 6:11 
GeneralOT: Finding a function in a disassembly. Pin
Brady Kelly1-Mar-09 1:48
Brady Kelly1-Mar-09 1:48 
GeneralRe: OT: Finding a function in a disassembly. Pin
«_Superman_»1-Mar-09 1:55
professional«_Superman_»1-Mar-09 1:55 
GeneralRe: OT: Finding a function in a disassembly. Pin
Brady Kelly1-Mar-09 2:46
Brady Kelly1-Mar-09 2:46 
GeneralRe: OT: Finding a function in a disassembly. Pin
Stuart Dootson1-Mar-09 2:29
professionalStuart Dootson1-Mar-09 2:29 
GeneralRe: OT: Finding a function in a disassembly. Pin
Brady Kelly1-Mar-09 2:36
Brady Kelly1-Mar-09 2:36 
QuestionStatic Library Issue Pin
dehseth28-Feb-09 23:52
dehseth28-Feb-09 23:52 
AnswerRe: Static Library Issue Pin
Cedric Moonen1-Mar-09 2:06
Cedric Moonen1-Mar-09 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.