jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And what the heck does tetron's first post have to do with anything in this thread?

I think is was one of those tests where you are watching the team is passing around the basketball so intently that when a guy in a costume walks through the court you don't notice it at all? Yeah, I guess maybe he copied and pasted his post into the wrong one...

@WaltP -- you're right. I made some assumptions and I should have kept it simple.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have tried it and I am not able to reproduce the error.

What happens if you run it from a terminal, not clicking on it to open it but if you open the terminal then change to its directory and type in the name of the file? (it shouldn't matter but try it)

So as of now you're clicking on the exe in the debug directory? and like I was asking before, the only change you made was to put in () after cin.ignore?

(btw, there's a stray "\n" on line 32 that's not doing anything. If you want it in that cout bring it inside the quotes).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is it that frequent to have a program that compiles ok but doesn't execute properly?

All the time. A loose analogy is that you can write something that has no spelling errors that follows the rules of grammar but makes no sense as a sentence once spoken or written.

Are you using the same code you posted before?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

True story from IIT Bombay

http://www.snopes.com/college/exam/flattire.asp .. and everywhere else.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

pictureBox1.BackgroundImage = Image.FromFile("sa-mp-042.png"); should work

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, you'll see later that if you want to use your object with cout you have to "overload" the << operator. If you don't have that in place and try to output an object (which is effectively what you did) the compiler panics. I'm still not sure why it does it 80 times but I'm sure there's a reason.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's a method, so you need cin.ignore();

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nope, not in this context. Char arrays can only be given a constant value when they are declared (I suppose you could have a great big chain of statements with choice[0] = 'y',choice[1] = 'e',choice[2] = 's',choice[3] = '\0' but that would be a little absurd.

You can use the comma operator for other things so if you had an int k, you could have j = 0,k = 0 and it would work fine.

There's a sure fire way to see if anything is going to work or not hehe. Test it out.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you using MFC or Win32 or Winforms (.NET)?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
int numbers[] = {10,20,30,50,70};
	float mean = AveArray(numbers,5);
	std::cout <<mean<<std::endl;
	float stddev = StandardDev(numbers,5,mean);
	std::cout <<stddev<<std::endl;
36
24.0832

Checks out on Windows Calc

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Leave out the second part like you said. You'll have to go up to the top where choice was declared and put char choice[] = "yes";

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you try testing your methods with a 4-5 element array like VernonDozier had indicated? Try that first. I know it may seem like a pain to break your code down (just copy and paste relevant portions over) but it will save you a lot of time in the long run.

Then, failing that, are the numbers huge and/or way out of proportion? In that case something may not have been initialized properly.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look into the finally {} block too. I regret that I don't have much expertise in this area.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

All you have to do is find the ", and if found, find the next ". Copy the stuff in between. It's simple.

Tokenize... sheesh! :icon_wink:

It's the fact that there may be string literals within the comments that he wants to ignore. /* "So if I"m parsing for quotes I'm gonna get this one" */ So you could just look for // and /* and lop off the rest of the line, but you'd miss something like "correctone" in function(/* "nevermind" */"correctone"), hence having to have some idea where your comments begin and end (enter the tokenizer).

If you were guaranteed there to be no string literals within the comments (my preprocessor idea) then it would be as simple as you propose!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's your first h matrix that's fouling things up. You are catching the exception of the first try, but then in the second one you're allocating the memory for it anyway. You end up creating a bunch of rows of 0 columns (that perhaps fail silently?) and so when you go to delete something that never existed you get the exception. That may not be exactly the case but it's something along those lines.
Exceptions in constructors are tricky and there's a lot written about them. I'm not sure exactly what you need but probably skipping that second try block when the first fails would work.
Your second h matrix clears fine, as it has it's own scope within the braces so it evaporates after that closing brace.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

j = 0 && choice = "yes" Is not going to work at all. You can't initialize choice after it's been declared, and using an && between those two could make sense in an obscure case but, assuming it would work, would only get you 0 in j anyway. Other than that, the way you have it is fine, I believe, except that you only ask for a name and not a telephone number.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Oh, c'mon, jonsca

Know your audience..

Noted. I didn't come up with anything earth shatteringly simple, so sometimes you need an elephant gun as a fly swatter. ;)
Personally, I think the preprocessor idea is the least difficult of all but I didn't try it to see if the line numbers are preserved. That way you don't have to worry about the comments because they are gone.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can post back what you have but I think you're probably so close to it that you'll find it without a problem.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See this. It's for VB but the difficulty is exactly the same. They say to add a PrintDialog to the form in addition to the webbrowser control.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For which setting? What you are looking for might be under Build.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A theoretical underpinning for all Windows software:
http://en.wikipedia.org/wiki/Stochastic_computing

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
#include <string>

Its string.h not string

It's actually #include <cstring> in standard C++.

For your infile stream you don't need to open up the file using open and then pass it into your inFile constructor. On line 16 you can just say ifstream inFile( ) with a null terminated string in the parentheses with the filename (so if it's a standard string it needs to be mystring.c_str() or a literal "myfilenamehere" or you can use the approach you used with open() in that function with the const). I would make an ifstream local to each function as above and not bother with the passing of the FILE pointer, or that function to open the file at all.

We've all got to learn sometime, so feel welcome to submit your questions (though it's a great learning experience to go through and figure out exactly what it is the compiler is telling you too).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What have you tried so far?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

havnt learned strings yet i dont think, but now i got some code:

#include <iostream>
#include <cmath>  [B]//Don't need it[/B]
#include <fstream> [B]//Don't need it[/B]
#include <cstdlib> [B]//Don't need it[/B]


struct peoples
{
    char person[20];
    char stick[80];  [B]//See below[/B]
    char discrip[20];
    int age;
    };
int main()
{
using namespace std;   [b] //Needs to be outside of main [/b]

peoples =       //[b] need an instance now, see below[/b]
{
    "this is bob:",
    "file for stickfigure here",
    "bob's age is: ",
    36
    }

system("pause"); [b] //lose this bad habit before you pick it up[/b]
return 0;
}

See my changes below:

struct peoples
{
    char person[20];
    char stick[3][6];  //3 rows of 6 columns
    char discrip[20];
    int age;
    };
int main()
{
     peoples mypeople=        //making a struct mypeople 
      {                                  //that is of type peoples
            "this is bob:",
           {"\\ O /",           //initializing 2D array inside
               "  | ",             //HW: why do we need \\ for a backslash
               "/  \\"},
          "bob's age is: ",
            36
     };
     return 0;
}

My code above needs the #include and using statements

Don't use system("pause"); see this use cin.get(); which will wait for a key.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You will need to either tokenize the lines and get rid of anything after // or between /* */
(You may be able to base what you do off of something like this: http://www.daniweb.com/code/snippet217441.html)

-or-
You can write a finite state machine similar to the ones that a compiler would use to detect and strip comments from a file (or even run your source file you are testing through the C++ preprocessor -- command varies from compiler to compiler -- to strip the comments before you run this program. I am not sure if that will preserve line numbers).

-or-
You can use a regex library (e.g. Boost Regex )and do something like this. Perhaps a bit of overkill but it's the same issue.

I wish I could have been of more help to you with an algorithm. I tried writing a bit of a finite state machine with just if statements but it got a bit cumbersome and I'm sure there are more efficient/faster ways of doing it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

#include <iostream>

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you give a typical line from the file?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I use the same compiler that's in C::B (mingw, which is the port of the Gnu Compiler Collection to Windows) from the command line for shorter projects and VC++ Express Edition for projects of more than a few files. C::B is a great program but I wasn't using many of the features.

You have to use what you feel comfortable with. Any setup will have it's gotchas. VC++ EE has a great debugger right of the bat. C::B has gdb which is awesome (I envy those who use it effectively) but has somewhat of a learning curve) and seems to integrate well with the environment.

Check out this thread too!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In your AveArray method:

float AveArray(int Numbers[], int Total)
{
	// Declared Variables
	int sum = 0;      //INT 
	
	// Just to make sure there isn't any junk values.
	float Mean = 0,0;
	
	for (int i = 0; i < Total; ++i)
		{
			sum += Numbers[i];  //INT
		}
		
	
	Mean = sum/Total;   // = INT/INT   **
                      
	return Mean;
}

** the result of integer by integer division is another integer (so truncated or 0 if numerator <denominator) which is then assigned to the float value.

Instead, cast one or both integers to a float: Mean = (float)sum/Total; or Mean = (float)sum/(float)Total; You're going to run into a similar problem with sum2 in the next one where you're trying to cram down the result of pow into your int. Making sum2 a float will make that situation better and it will ensure that you don't have the same truncation problems in that method too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In the + operator code, change

return matrix (*this) += in;

-to-

*this += in;
return *this;

It seems to work...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You really have 2 different main() programs that you are trying to compile as one unit. Split it up into two.

In the first file go from the headers to the first closing brace.

In the second file copy in just the headers (#include, etc), add in an int main() , copy in the stuff between your second set of braces and you're in business.

Please use code tags they will preserve spacing and put in line #s:

[code]

//code goes here //code goes here

[/code]

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yep. I glanced too quickly and didn't think about the newline after the final int was read in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Disregard the above, I didn't see that you were trying to do that on purpose further down in main().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put in a cin.get(); between lines 33 and 34. This will effectively wait for a key to be pressed.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

S= standard deviation = square root of (sum/N)

FWIW, and I don't think it affects it too much for OP's purposes, it should be N-1 instead of N since it's a sample from a population (unless you have enough data to justify a population). Not knowing the population gives you one less degree of freedom.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I didn't immediately find the solution to the problem but part of the problem is in the += operator, it keeps saying your matrices are different sizes and returning *this.

if ((column!=in.getColumns())||(row!=in.getRows()))
{
	cout <<this->getRows()<<" "<<this->getColumns()<<endl;
	cout <<in.getRows()<<" "<<in.getColumns()<<endl;
	throw invalid_argument ("Matricies must be of equal size.");
}

I get 3 4 for a which is presumably correct but 5 5 for b which is not.

Just wanted to give you a lead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The return 0; is implicit and the std:: qualifier on cout means that you don't need the using namespace std; line.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You forgot the car:: on the last three methods.

What you want to be returning with the getDoors() is carsDoors. The names of the private variables must match up exactly. The reason you have some leeway with the method parameters is that the names are essentially local to that method. Think of your methods as being a go between for the private members and the outside world.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

One of the biggest things Visual C++ 6 supports that newer versions do not is the prestandard headers:

The math.h/cmath is along the lines of which Narue expressed. I hadn't thought of that exact thing, but now I know :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

... or the NRA. Hehe. Whatever they're calling it these days.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Make it so that your if statement looks for the vowels, then have else if look for the consonants (hint: all the vowels will be filtered out by the first stage so you don't have to be so fussy about the ranges), then have else determine not-a-letter status.

if (get the vowels)

else if (get the consonants)

else ( not a letters automatically here)

Draw it out on paper if you are still having trouble.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That would make sense. I'm still messed up with the circular list hehe.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your copy constructor is crashing also. I've had a little bit of luck with the concat method. Are you sure that you want your tail node pointing to your head node? I think it might be easier if it pointed to null but that's just me.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use *this to access the calling object. Simply attach head of the passed in sequence to the tail of *this (and connect tail of the passed in sequence to the head -- I think that's what you did in the other methods). Then at the end of the method just return *this (and make sure you change the return type to (Sequence &) in the definition and declaration.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

why don't you add some C4 along with TNT

That's not in the spirit of your moniker. Don't you mean some drain cleaner, 2 nickels, a rubber band, and a highlighter?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do your applications use either the MFC (MS Foundation Classes) or the ATL (active template library)? Those libraries are only found in the Standard Edition and higher. Otherwise VC++ Express only supports pure Win32 and Winforms for C++/CLI.

I'm not absolutely sure what in terms of the actual C++ standard was implemented from version to version. I know there's a listing of things that are still non-standard for each generation (they don't have one for 6.0 any more but here's the one for 2008 (you can get them for as far back as 2003 edition on the right side of that window).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The worst part was trying to google "->"

Yeah, I've been through that myself. I've never found a way around it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think your concatenate method should return a reference to a sequence object so that once you've concatenated s3 or s2 onto s1 then your copy constructor can work on the reference to the new sequence. As it is without the reference it's trying to use Sequence::Sequence(Sequence) but there is no such copy constructor.

concatenate() is kind of flimsy as it is. You declare a sequence (local to the method, so it will go poof at the end) seq3, but then you declare the head and the tail and you do the manipulations with those but then at the end you return seq3 after nothing (that I could see anyway) is happening to it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

169 C:\Users\...\sequence.cpp 'class Sequence' has no member named 'conacatenate'

There may be other things wrong but did you read this error message carefully? You have a typo in there somewhere. Sequence s3 = s1.conacatenate(s2); Right there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For a class or a struct that's being referred to by a pointer, -> represents the dereference of the pointer followed by a dot operator.

For example say you have a class MyClass and public member function myMethod:

MyClass * mycl = new MyClass();
mycl->myMethod();
would be the same as
(*mycl).myMethod();