We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,127 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Creating filled/unfilled rectangle class.

I'm trying to create a filled and unfilled rectangle class. I can easily create the filled, but the unfilled one is giving me a little difficulty. Whats going on?

void Rectangle::drawrec() 
{
if (filled == true) 
{ 
for (int row = 0; row < height; row++)
{ 
for (int col = 0; col < width; col++)
{
cout << "*";
}

cout << endl;

}
}
else

{
for (int row = 0 ; row < height; row++)
{
for (int col = 0 ; col < width ; col++)

{
if (height != width)
cout << " * ";

}

}

}
2
Contributors
1
Reply
8 Months
Discussion Span
1 Year Ago
Last Updated
2
Views
stan2000
Newbie Poster
6 posts since Mar 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0
else
{
for (int col = 0 ; col < width ; col++)
{
for (int row = 0 ; row < height; row++)
{
if(col==0||row ==0||col==width-1||row==height-1)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
}
mazzica1
Junior Poster
148 posts since Oct 2011
Reputation Points: 9
Solved Threads: 27
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0578 seconds using 2.65MB