jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've omitted and mismatched. You don't even call your function. At least try to get it to compile before you post--and if after that you have a "unbeatable" error, at least let us know what it is.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, what do you consider to be the essential features of OOP? One hint: what kind of inheritance does C++ support vs. Java. I didn't do a net search but I'm willing to bet if you google this you'll come up with tons of "ammunition." Keep in mind that each language's implementation has it's pluses and minuses and more is not always better.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Being adroit in Detroit is so gauche!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Starting on line 84 there are some errors that,while they compile, they are not doing what you expect.
84: Where is i coming from? I see where it's declared but there's no value assigned to it anywhere and it doesn't change in the while loop
93,97: Should be == instead of = , you had it right prior to that

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Since there is no inheritance type specified, the default is private. Therefore your public and protected members become private and your private members are not accessible to your derived class. Your protected variable from A is then becoming private in B, which is then not accessible from C.

I think the solution is to use public inheritance:

Class B: public A
{
};

Class C: public B
{
};
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

NumericUpDown is a Winforms control in .NET.

@OP- I tried a couple of times to get WaltP's idea (and using this article for VB) to work but for some reason when I would try to wrap around I would get a StackOverflowException.

The solution is using a DomainUpDown control (in Toolbox go to All Window Forms). In properties, turn Wrap to True and set Text to your initial value. In your Form1_load event populate the list with a for loop:

for (int i = 0;i<100;i++)
      domainUpDown1->Items->Add(i.ToString());

Next make a button or whatever will do your bidding:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
      int value = Int32::Parse((String ^)domainUpDown1->SelectedItem);
      int newvalue = value*10+5; //for illustrative purposes
      MessageBox::Show(newvalue.ToString());
}

It's a little bit kudgy to go back and forth from string like that but if you really need the wraparound feature it may be the way to go (I'm not completely dismissing the NumericUpDown but it may have been designed (but to what purpose?) to function without wrapping)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, I made one from your first post. It displayed on the screen when the program started. The only change that I made was that I put it in the same directory as the exe, so I took the C:\\ off of the filename string.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Post how you changed the code... I changed the prototype and the definition and it lets me enter the coordinates (then it does nothing so I'm not sure what to expect), but I don't get a stack overflow.

Just a curiosity question: how come you didn't have solveMaze return a bool? (I get your #define but it's kind of archaic when there's a bool type)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Functions can go before main() as you have it, or they can go after main() but in that case you'll need a prototype before main to tell the compiler what to expect later on.

In your example, for your method SearchN int SearchN(vector <string> &lastname, string searchName); or simply int SearchN(vector<string> &, string); would have to be placed before main().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I took your advice but I get but I am getting errors that total isnt declared, getAvg doesnt take 2 arguments, among others when I try to change student and school, etc.

Probably should repost the code since I don't know where you added and subtracted stuff. Once you get it running it would probably be good to try what vmanes proposed.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Too-shay is wrong it should be pronounced toosh - so you can keep up the rebellion.

It's more fun to pronounce like "tushie." Oh my that's quite gow-chee of me.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would drop MFC like a hot rock and learn up on WPF

A caveat to that is in order to access the managed libraries one must code in C++/CLI which is in some cases more similar in syntax to C# and yet has its own syntactic quirks like handles.
The current express edition (and I think the standard edition) has WinForms capability and a designer but I don't believe either edition has a WPF designer for C++ (so you can't take advantage of the XAML). I checked on the 2010 version and it doesn't seem to have it either.
And so my font of knowledge has run dry. ;) Executing a net search on any of the keywords should get you lots more information.
Dusktreader's advice is sound and looking towards the future is the best idea. The moral of the story is look into what baggage a particular technology brings along with it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Those rabid anti-leftites.

Better an anti-leftite than an anti-Dentite

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In your construct method add a null terminator to your string (so at the index after the last used space add '\0' then use a ! = '\0' instead of a !=0 ( = 0 might work, but I don't know for sure offhand). So essentially give your counting routine something to end on. It's probably a little bit safer too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No. The 2008 compiler is more compliant with the C++ standard (see something like this for the few ways the 2008 compiler is not compliant-- they don't have a listing for 6.0 any longer) so it may pick up more corrections but it will make your code more compliant by extension.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I believe it's a known problem. I don't have a solution offhand but unless you are needing 6.0 for MFC or ATL work then you should probably grab the 2008 express edition (http://www.microsoft.com/express/Downloads/#2008-Visual-CPP) it does console programs, Win32, and Winforms via C++/CLI.

Ancient Dragon commented: Good advice. +26
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So if you call your getUnitPrice() within your computeTotalPrice (so just say looping through your inventory without the if statement making the comparison) what does it say the prices are?

You can still use your char array in the getline() if that's what you are asking. Just pass it in without brackets.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

#include <cmath> not cmath.h

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I just was joking that your sentence trailed off without being completed (unless it's a problem with my browser or something but that's where your post ends on my system). I wasn't poking fun at what you said.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is there anything in FromInventory once you get inside of your method? I would verify it contains what you think it does and is as long as you expect.

Second thing with the name is straightforward. Change your cin to a cin.getline(InputName,10); that way it will get the spaces and you won't overrun your char array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In the whole "Is this word really used" debate no one brought up its use in Organic Chemistry (http://en.wikipedia.org/wiki/Gauche_effect). Scores of college sophomores are introduced to it and they don't even know how lucky they are.

@GrimJack, I always find it fun to pronounce adroit as English. It feels like I'm rebelling against that French class feeling. Now if only I can get that gow-chee pronunciation to catch on.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also as a good practice and coding convention, keep the

That's the equivalent of "The...secret...of...the...universe...is" (*slumps over). Perhaps we'll never know.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

OP, the Linux man (Salem) has spake. :) I wasn't sure whether it was a good idea so I'm glad you came along. I'd always done the ./ thing but I don't use the *nix on a regular basis enough to know all the tricks and shortcuts and how they break down.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm assuming you pick a random position? There may be a shorter way but you probably have to use strcat with something like strncpy, etc. I don't want to steer you incorrectly, so try it and see what you can come up with and someone will probably be able to help you optimize it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a look at the example on this page. Is that what you are trying to do, except with digits?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Firstly, please use code tags (there's still time to edit your post and put them in).

For your for loops, you are incrementing your values in your initialization step (and thereby skipping over the first value) and you were losing your last (if you want it) by having a termination condition that was < instead of <=: for ([COLOR="Red"]f++[/COLOR];f<l;f++) in both cases
Use a different variable if you can and have for (int index = f;index <=l;index++) (for example) In that same vein don't use 1 letter variable names, there's no savings there and there is a decrease in readability.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The best way is to pass your struct around (you did it by reference into getInfo() which is fine) So change the prototype of getAvg to take a school & also int getAvg(school &, int total); instead of a student (which isn't known about until you made a variable student of type school in main. Just leave the call to getAvg in main() as it is.

I suspect that in time you'll make an array of structs so you can have multiple students but that will require a few name and type changes.

EDIT: V beat me to it

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to type ./a.out (or if your program is named with the -o switch) ./nameofyourprogram

See here for an explanation that has a way around it (I'm familiar with the problem but I'm not so much a Linux guy so I don't know the dotfiles as well to advise you one way or another).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'd bet a bit that there is a lot of C code in that field from the embedded systems that all these secret agents walk around with (never saw a security person, laptop in hand, chasing a perp, have ya?)

(which could also mean for the C++ guys that they cross-compile to a lot of different platforms not available to Java)

(but Niek_e is your honest to goodness embedded guy so he knows this stuff much much better than I do)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Great. Keep on with it it'll turn out great. All you need are some air resistance calculations on the dart in mid-flight.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I thought the r statement was the meat and potatoes of your program though. Do you see why everything is less than or equal to 3 if r = 0? What kinds of weird values were you getting?

The quickest way (not necessarily the best way) would be to test x and y after the cin statement for being less than or equal to -100, if so then return 0; on the spot. There are probably cleaner ways to do it by breaking out of the while and testing for a flag, etc. etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where did your calculation for r go? It looks like you set r = 0 in that method which will then hit the first if statement and return 100. I would change that chain into an else if construct rather than a bunch of ifs one after another.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

int score1 = 0,score2 = 0; (put that in place of int score1; int score2; ) Now they have been initialized (pardon the omission on my part).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Next term's lecturer probably offers the question:
"Why is the programming language Java often used as the main programming language for Biometric Applications compared to C++ the programming language?"
(or was it in fact a carefully crafted contest to see who could put the most 'programming language' statements in one sentence....)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I totally understand. I was more kidding around than anything. Well ya can't get any more American than that. And that is certainly not gauche.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This, or use a for loop:

int i = 0;
int score1,score2;
while (i <6)
{
       cout <<"Player1's turn:"<<endl;
       cout <<"Enter x and y"
       cin >> x >> y;
      score1 +=score(x,y);

      //same thing for player 2
       i++;  
}

You could do something fancy where the loop only had 1 cin statement and updated the score in a 0 or 1 position of a 1 x 2 array depending on which player was up, but that might be too much of a headache (using % operator).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are some of the reasons you would propose? (since clearly you're not asking this for homework or anything ;) )

Also note this is one of those questions where your professor may think there is a right answer but unless you're talking about % total of software projects in a field being dominated by one language versus another it's tough to compare.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I just responded on your other thread. lol When you have a chance you should flag down a mod (you can hit your own flag bad post) and have them close one (or merge them, but I think closing's easier) so it doesn't get confusing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think what you ultimately want to do is have a while loop that governs a turn-based system.
I'm not precisely sure where your difficulties lie in the above steps. You should have a player1score and a player2score. In the turn based system I was proposing you would take in x and y for player1, run them through the score function, get the score back. Add that score to the existing player1score. Then repeat that for one run of player2, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Start a new project in VC++ this time uncheck precompiled headers and leave empty project unchecked. Add your files to the project by right clicking on the solution/Add.. etc. and you can clear out all the other files (or just exclude them from the project to be safe). You've probably done everything correctly except for the precompiled headers part.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are there any additional libraries from which you are trying to use code? I'm sure this has nothing to do with it, but you should change <stdlib.h> to <cstdlib> (akin to the cmath change).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's looking for a main() with the 2019 error. It needs some type of entry point to make the exe unless you are making a library (which I didn't read your other thread but it doesn't sound like that's what you're doing).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah, no that's what i saw. It's probably a cleaner approach. It's all good. I was just warning OP about the cast.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For next time, please use the code tags

[code] //code goes here

[/code]

Count needs to be initialized to zero before the loop, otherwise you're getting whatever junk is in there upon declaration. If you want a space in your output just do outfile<<firstName<<" "; or wherever you want the spaces.

You are right in wanting to take it one step at a time. Once you get this part working try to write out your other values and see what happens.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Add it back in again to your sum. You'll need to make one small change to your if statement (the one to find the minimum) so that it doesn't get -999 each time. average = sum/count; Also see post #20 ^^^^ why this is going to be problematic.

EDIT: Fbody's approach will do too but it doesn't affect the last concern about average = sum/count;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And some of us hate baseball.

Hey, nobody's perfect. :D

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Both y'all are yankees

Some of us are Red Sox fortunately ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's even more gauche to pronounce it "Gow-chee." That's just plain meta-gauche.

mrnutty commented: Touche` +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For next time, don't necessarily start up a new thread when people might still be working on that exact same issue in your old one, it gets too confusing.