I did disable all commands of other functions.
Here is my Screen class:
class Screen
{
private:
char* pixels;
int height;//rows
int width;//columns
public:
friend ostream& operator<<(ostream & out, const Screen & TV);
Screen(int=10, int=10);
Screen(const Screen&);
~Screen(void);
void setH(int );
int getH(void)const;
void setW(int);
int getW() const;
void setPoint(const Point&,char);
void resetPoint(const Point&);
void clear(void);
void draw(void)const;
};
// implementation of screen class
Screen::Screen(int r,int c)
{
int size;
height=r;
width=c;
size=r*c;
pixels=new char[size];
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
*(pixels+(i*c)+j)='.';
}
}
}
Screen::~Screen(){delete []pixels;}
void Screen::setPoint(const Point & object, char c)
{
int i=object.getX();
int j=object.getY();
*(pixels+(i*width)+j)=c;
}
void Screen::resetPoint(const Point& object)
{
int x_del,y_del;
x_del=object.getX();
y_del=object.getY();
*(pixels+(x_del*width)+y_del)='.';
}
void Screen::clear()
{ int i,j;
for(i=0;i<height;i++){
for(j=0;j<width;j++)
*(pixels+(i*width)+j)='.';}
}
void Screen::setH(int row)
{
height=row;
}
int Screen::getH()const{ return height;}
void Screen::setW(int col)
{
width=col;
}
int Screen::getW() const{ return width;}
void Screen::draw()const
{
for( int i=0;i<height;i++)
for( int j=0;j<width;j++)
{ cout<<*(pixels+(i*width)+j);
cout<<endl;}
}
ostream& operator<<(ostream & out, const Screen & TV)
{
for(int i=0;i<TV.height;i++)
{for(int j=0;j<TV.width;j++)
out<<*(TV.pixels+(i*TV.width)+j);
out<<endl;}
}
for the moment my main is:
int main()
{
Screen ecran(20,30);
cout<<"\n\nPrinting a blank Screen"<<endl;
cout<<ecran<<endl;
return 0;
}
It is the only changes I made beside the the two I did show above.