|
-
October 27th, 2002, 10:12 PM
#1
why i can't assign I[5] ?
#include <iostream.h>
class A{
private:
int x,y ;
public:
A(int a=0,int b=0){y=b;x=a;}
void init(int a,int b){x=a;y=b;}
void show(){cout<<x<<" "<<y<<endl;}
};
void main()
{
A l[5]={(1,1),(2,2),(3,3),(4,4),(5,5)};
A *p;
p=l;
l[3].init(8,3);
p->init(3,4);
for(int i=0;i<5;i++)
(*(p+i)).show();
}
when i execute this code,I[0] was shown (1.0),but I assign it (1,1),i[0] was not assigned.so was i[1],i[2]...
What can i do to assign i[5]?thanks very much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|