Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
i want to write a program with class can move this:

***
*+*
***

i want to move this with 2 classes i explained here tanx
class pls
{
    public:
    char b[8];
};
class star
{
    public:
    pls c[8];
};
 
int main()
{
    star box;
    for(int i=0;i<8;i++)
    {
    box.c[i].b[i]="t";
    }
Posted
Updated 1-Nov-11 0:30am
v2
Comments
Andrew Brock 1-Nov-11 6:31am    
I have no idea what you mean. Are you trying to move the + around?
Member 8325631 1-Nov-11 8:33am    
no all object together move to right
Maximilien 1-Nov-11 8:44am    
just print X number of "space" before each line of text.
Member 8325631 1-Nov-11 9:10am    
can u help me more?
Member 8325631 1-Nov-11 9:11am    
i dont want to use space

1 solution

hi dear
did you mean "tab" from "t"?
i think you need it:
_______________________________________
class box{
public:
void move();
private:
char b[3][100];
int interval;
box();
};

box::box(){
interval=0;
b[0][0]=b[0][1]=b[0][2]=b[1][0]=b[1][2]=b[2][0]=b[2][1]=b[2][2]="*";
b[1][1]="+";
}

void box::move(){
interval++;
for(int j=0;j<3;j++){
for(int i=0;i<3;i++){
b[j][interval+i]=b[j][interval-1+i];
}
b[j][interval-1]="\t";
}
}

int main(){
box b;
b.move();
b.move();
...
}
 
Share this answer
 
Comments
Richard MacCutchan 13-Nov-11 4:00am    
Use <pre> tags around code samples so they are readable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900