|
In order to make your include files visible, you need to check the 'display message as is' checkbox under the message as you type it.
Your problem is that your if/else statements are not scoped.
If I were to run this:
int i = 1;
if (i==0)
cout << "it's zero ";
cout << "I wish it was one ";
cout << "it's one";
the result will be
"I wish it was one it's one".
Python scopes things in blocks, C++ does it with the curly brackets. Unless you do this:
int i = 1;
if (i==0)
{
cout << "it's zero ";
cout << "I wish it was one ";
}
cout << "it's one";
the language will automatically only make the first line after the if statement conditional on the statement above it.
In this case, it's kind of pointless making the type a variable and then outputting the type directly, you should instead just print the value in the variable after deciding what sort of triangle it is.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Try this
if ((side1 == side2) && (side2 == side3) && (side1 == side3))
{
equil = EQUIL;
cout << "This triangle is an " << equil << endl << endl;
}
else if ((side1 == side2) || (side2 == side3) || (side1 == side3))
{
isos = ISOS;
cout << "This triangle is an " << isos << endl << endl;
}
else;
{
scal = SCALE;
cout << "This triangle is an " << scal << endl << endl;
}
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
Gary....thanks for your help.....this would work expect for my else statement at the end state that the triangle is false. I need to find a way to have the three different kinds of triangle be with if it is a triangle statement. I only want to prove if it is a triangle and what kind. If it's not a triangle then have my else statement stating it.
Sorry about this problem I'm having!!!
Autumn
|
|
|
|
|
You need two nested if statements, the first to establish if it's a triangle, the second to establish what sort. You should also output the type of triangle once, based on the variable you set.
You should also put using std::cout; and using std::cin; instead of using namespace std; - there is no point having namespaces if you're just going to negate them in one fell swoop.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
there is no point having namespaces if you're just going to negate them in one fell swoop.
maybe you should take up the "using" keyword with the C++ standard body.
-c
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|
Chris Losinger wrote:
maybe you should take up the "using" keyword with the C++ standard body.
According to Stroustrup, using an entire namespace is useful if it is within a limited scope, and has other application ( I forget the rest, and don't have a copy at work ), but should generally be avoided in favour of the syntax I suggested.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
According to Stroustrup
yeah yeah. the same guy who decided that "static" needed yet another meaning.
-c
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|
Now you're just trying to wind me up......
I agree with him in principle that new keywords should be created sparingly, but a lot of mistakes get made in the pursuit of noble goals.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
Now you're just trying to wind me up
never.
Christian Graus wrote:
but a lot of mistakes get made in the pursuit of noble goals
oh, i agree.
-c
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|
Thank you for all of your help....I think I'm just having a hard time understanding how to write it out in C++. My code still isn't working.....boy this is just a pain in the tush. Thanks for all of your help.....I guess I'll just keep on sinking on this program. Keep smiling...and remember today is today....don't drag it to the next.
Autumn
|
|
|
|
|
#include < iostream >
#include < string >
using std::cout;
using std::cin;
using std::endl;
using std::string;
const string EQUIL = "equilateral";
const string ISOS = "isosceles";
const string SCALE = "scalene";
void DisplayOpeningScreen();
void Print6BlankLines();
int main()
{
int side1 = 0;
int side2 = 0;
int side3 = 0;
int halfper = 0;
int area = 0;
string sType;
DisplayOpeningScreen();
cout << "\nEnter first side of triangle: ";
cin >> side1;
cout << "Enter second side of triangle: ";
cin >> side2;
cout << "Enter thrid side of triangle: ";
cin >> side3;
if ((side1 + side2) > side3 && (side2 + side3) > side1 && (side1 + side3) > side2)
{
cout << "\n\nThe three lengths can form a triangle.\n\n";
if ((side1 == side2) && (side2 == side3) && (side1 == side3))
sType= EQUIL;
else if ((side1 == side2) || (side2 == side3) || (side1 == side3))
sType = ISOS;
else;
sType = SCALE;
cout << "This triangle is an " << sType << " triangle. \r\n\r\n";
}
else
{
cout << "\n\nThe three lengths can not form a triangle.\n\n";
}
Assuming the maths is all right ( I don't know ), this should work fine. Note I do not call endl over and over ( it does a flush as well and can be expensive ), I initialise my numeric variables, and I use only the bits of std that I need.
return 0;
}
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Thank you for everyone's help!!! I finally got it and I'm so happy. I hope you all the best and thank you once again!!! Have a great night!!
Autumn
|
|
|
|
|
I need help with dialog toolbars. I am trying to create one, but I haven't figured out how to get the toolbar to "appear" enabled. It works, but the titlebar of the window is grayed. Is there any way to correct this?
-- Steve
|
|
|
|
|
Have you checked out this article[^]?
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Is there any reason this shouldn't work on 9x machines? It displays fine on my 2k machine but not on 98..
void CStatusBarEx::OnContextMenu(CWnd* pWnd, CPoint point)
{
if( point.x == -1 && point.y == -1 )
{
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);
point = rect.TopLeft();
point.Offset(5, 5);
}
CMenu menu;
menu.LoadMenu(IDR_STATUS_BAR);
CMenu* pPopup = menu.GetSubMenu(0);
CWnd* pWndPopupOwner = this;
while(pWndPopupOwner->GetStyle() & WS_CHILD)
pWndPopupOwner = pWndPopupOwner->GetParent();
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, pWndPopupOwner);
}
|
|
|
|
|
|
This is the sort of question you should look to MSDN for an answer. All you're asking is how do I use pens and brushes on a bitmap, and there is plenty of documentation on that to go around.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
i've tried doing it from the examples in MSDN, but it's not working, so i wanted to see how you do it.
|
|
|
|
|
OK - some advice:
1. If you want to be taken seriously, try getting an account instead of posting anonymously. I obviously have answered anyhow, but a lot of people don't.
2. Seeing as everything I do with GDI I learned from MSDN, it's obvious you're doing something wrong. Any code I write seems as likely to cause you trouble as the MSDN samples. Posting some code would both show that you've tried to do it for yourself ( as opposed to just coming here and trying to be spoon fed ), and would also encourage people to help you. More importantly, it would mean that we could quickly tell you what you've done wrong instead of having to type up full examples for your benefit.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hi,
I'm trying to develop a table control like Chris Mauder's GridControl. And like in GridControl or MFC's list control i created a struct to contain the elements to set for cell properties.
Now i wonder, instead of using a struct and specifying the mask variable so that it will understand which properties we want to change, can't we use a class and set all variables to NULL in the constructor? That way we wouldn't need to '&' the mask with predefined mask values and see if it's set or not, we could just check every variable if it's NULL or not.
Well, this makes sense to me but i need advice from experienced programmers.
Thanks in advance.
|
|
|
|
|
A struct is the same as a class, except it's members are public by default. There is no reason you cannot specify a constructor for a struct.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
ok, so is it ok to specify a constructor in a struct or class and assign NULL to all variables and not to use masks as i mentioned in my previous post?
Thanks.
|
|
|
|
|
I think Daniel has answered your core question more directly, but I just wanted to note that a struct is a class, with only the one difference.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
i understand and apreciate it. Thank you.
|
|
|
|
|
Bit flags are widely used for performance reasons, not for style reasons. In a pure OOP, you're right. And maybe, using inline functions we could accomplish the same thing.
But, as I've said, programmers are so accostumed to do things this way, that they won't change so soon.
The other reason to do this is that it's much easier to change this flags using a single window message (WM_*) than to do it dispatching a ton of messages.
In some API calls this is also used to reduce the number of parameters. Ok, this could also be done with unions and bitfields but, it's so easy to do a ACCESS_READ | ACCESS_WRITE when calling a function, that's still done this way.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|