hi
I am using myclass to define a vector .
but I can not write values of member variable 'a' .
please tell me how I van use member variable 'a' in printf command.
thanks a lot
I am using myclass to define a vector .
but I can not write values of member variable 'a' .
please tell me how I van use member variable 'a' in printf command.
thanks a lot
Code:
#include <vector>
#include <stdio.h>
class myclass{
int a;
}
using namespace std;
int main()
{
myclass m;
std::vector<myclass> v;
m.a=10;
v.push_back(m);
m.a=20;
v.push_back(m);
vector (myclass) :: iterator it;
myclass *s;
for (it=v.begin();it<v.end;it++)
{
s=it;
printf("a=%d\n",s->a)
}
}
Comment