finally i put it to work:
Code:
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
class test1
{
private:
public:
static int stcintCount;
static vector<void*> vdTest1;
string a;
test1()
{
stcintCount++;
vdTest1.push_back(static_cast<void*>(this));
a=to_string(stcintCount);
}
test1 &operator[](unsigned int index)
{
test1 *tstTest;
tstTest=static_cast<test1*>(vdTest1[index]);
return *tstTest;
}
};
int test1::stcintCount=-1;
vector<void*> test1::vdTest1;
test1 tstCount1;
test1 tstCount[4];
int main()
{
for(int i=0; i<4;i++)
cout << tstCount[i].a;
//cout << strName;
return 0;
}
output:
1234
another sample:
Code:
test1 tstCount1;
test1 tstCount[4];
int main()
{
for(int i=0; i<=tstCount1.stcintCount;i++)
cout << tstCount1[i].a;
//cout << strName;
return 0;
}
output:
01234
using a void* vector, i can save all instances pointers
now i can do what i need, except use the class name
but it's cool. thanks for all