jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you check line 13 like the compiler was telling you to? You only need a semicolon after a prototype but not in the function definition.

What I was also saying before is do you want to increment a and b within your function? Remember this will change the values outside as well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I should use it like this cuz we kinda study it like this and I don't wanna mix things up

Okay, but just be aware that for all the rest of the programming world, we like to leave 1993 right where it is.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You missed the obvious option, jwenting. Open the skull, put black ink over the cortex, stamp it on a sheet of paper. Voila, brain fingerprinting.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check line 13 (and line 17 for good measure). One has something it doesn't need and the other needs something.

mitrmkar commented: line 13 == good catch +5
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

By the way it should be #include <iostream> not iostream.h which is an outdated prestandard file. main() should be of int type (the way you have it, it's probably implied but that's not a good habit to get into).

Also, what if you wanted to use x and y further along on your program. There might be a problem there...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Get rid of the z= on line 9, and pass in the address of z as the third parameter (just like you did with x and y).

Now, in your function you must actually do the calculation with *c (as changing a and b will do nothing to c).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are potentially a few issues here.

If the document is up and running in word it may be locked as far as the file system is concerned (I have not tested this).

If you are trying to read from a Word document in text mode (as in from a .doc file from a recent Word release) instead it needs to be a binary read/write (unless you are doing word 2007, in which case it's in XML).

If you are simply trying process between (plain) text files leave them closed and let your program do the opening, closing, and creating of the new file.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a quick look at an ASCII table (http://web.cs.mun.ca/~michael/c/ascii-table.html for example) as to how 'a' relates to 'A'

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hi, I am working on visual studio 2008 C++ and I have done the C++ general code, my question is can I convert my general code to be C++ CLR in visual studio 2008? This will make my work easier.

This is an excerpt from a book by Nishant Sivakumar that has a nice chart about handles versus pointers in section 1.4. To answer your question almost any code is "convertible" but the extent to which you have to marshal between managed and unmanaged types will vary.

And I have one more small question is I have made a textbox in C++ CLR, how can I load text from a text file? It is easy to load text file under C++ general but in CLR I don't know yet?

Thank you!

Use streamreader. Create the object with the name of your textfile and use Read, ReadToEnd or ReadLine methods.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are no conditions on an else statement. You could have an else if with conditions but I don't think that's what you need here.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You probably need a cin.ignore() after line 13 to sop up the extra '\n' but I can't see firstChoice() to verify that.
When you take in a character and press enter the newline hangs around in the buffer and gets taken in by the next function looking for input (your getline() in choice 4). getline() reads the '\n' which is its delimiter and finishes all without getting a filename.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

cols = 2, right? I had made a goof on my cout (I had the old value for the formula) but I had it right when I was actually doing the manipulations. See my test program.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's not what I got, I just tried it you run off the end of the array. I had along the lines of copy[i] = copy[i]+ (A[(i % cols)+(j-1)*cols])*(B[(i/cols)+(j-1)+(i+1)%cols]); Since the i value is the same you don't need to change that first array indexes at all but you have to follow that 2/3/2/3 pattern for the second array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You did fine with this posting. Sometimes it's nice to put something like your text there (sample output) into code tags to keep it neat. I've got to admit I really haven't much of an idea about the requirements or the goals of the program. Could you post the stores.data (if it's not too long)? I think you were trying to show me what the output is currently from those two functions but it would also be good to see what it is supposed to look like.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
struct addressbook personaladdressbook[50]
{
  char name [NAME];
  char address [ADDRESS];
  char phone [PHONE];
  char email [EMAIL];
  char Target[NAME];
} addresses[NUMAD];

With this we've confused you a bit, remove both additions from this block. To instantiate a struct do either:

struct mystructname{
//members here - left out for clarity
} mystructarray[50];
and nothing in main

-or-


struct mystructname{
//members here
};
and then in main()
struct mystructname mystructarray[50];

If you make it in main, you're going to have to pass a copy of the struct into your methods (and keep track of the number of entries out in main). If you make it in the first way the array of structs is global and you can access it directly. The first way is probably neater and preferable.

However: I'm looking back over your code and noticing that you aren't really trying to keep an array of the names and addresses at all. It seems like you might not even need the struct. If you need to keep it as part of your requirements just put:

struct addressbook{
//other members here
}myaddressbook;

and rename all of your references to addressbook in Insert() etc to myaddressbook. Apologies we got you going on this array route. I just didn't understand that all you were doing was populating the struct and then writing it out as raw strings anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you give a sample input/output session (a limited one)? Also, your variable declarations should all be at the top of a block (e.g., at the top of main()) in order to be standard.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Wrap from lines 6 thru (and including) 43 in a do/while loop. Instead of having the if and else if use c == 'y' as your condition of your do/while.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a closer look at your index on your b.data_ vector on line 15.
The pattern that you have is this:

i,j,index of A,index of B
0,1 0 0
0,2 2 1
1,1 1 0
1,2 3 1
2,1 0 1
2,2 2 2
3,1 1 1
3,2 3 2

Now if you go through the calculation by hand that's not the right order for the i = 2 and 3's (it happens to work for the i = 0 and i = 1 cases)
For those you need something like this:

i,j,index of A,index of B
2,1 0 2
2,2 2 3
3,1 1 2
3,2 3 3

See what you get for the equation and then we can compare.

Also, you need to clear copy before each time you go through the js, that's why your answers were so high.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i want to be able to call a function from there to the array of individuals..how would i do that?

I'm not quite sure what you mean by that. Can you give a brief example? (just conceptually)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Note: this one doesn't mind that it don't forward declare Train, I figure this means it's getting Event.h forward declare of it, or I was wrong in my previous statement saying they're not giving me trouble, I haven't tested them individualy yet.

Arrival shouldn't need it then either then as it's part of Event.h. It's possible that's goofing you up too. Well, try all the suggestions and see what happens.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have not made an instance of your struct like:

struct addressbook
{
  char name [NAME] ;
  char address [ADDRESS];
  char phone [PHONE];
  char email [EMAIL] ;
  char Target[NAME];
} addresses;

In fact you probably want an array of them so #define the number of addresses (say NUMAD) you need and change addresses as above to addresses[NUMAD] or the like. You'll have to keep track of the current count of addresses somewhere so you don't overwrite the information. This way you can have more than one entry.

Another option would be to declare an instance of your struct in main and pass that into your functions.

Ok, so there's going to be some rewriting to do but it shouldn't be too bad. Post back with any questions.

EDIT: AD beat me to it ^^^^^^^

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

but what I have here completely makes sense..

To you maybe, but it doesn't work for the compiler. The other poster was correct.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It doesn't do anything the way you have it. That's not what AD meant.

Matrix::Matrix(int mdim_, int ndim_)
{
  this->mdim_ = mdim_;
  this->ndim_ = ndim_;

is very different than what you have there. This is saying take in two arguments mdim_ ndim_ via the constructor (which happened to have the same names as your internal variables but don't have to be) and set them to this->mdim_ and this->ndim_ (which are the internal variables). This way everything is initialized. As gashito reinforced there are variables left uninitialized the way you have it set up now.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Question:

mdim_ = mdim_;
ndim_ = ndim_;

what is the point of this? It doesn't affect your problem but it seems prone to error and completely unnecessary.

Which leads me to the next point of: look which constructor your are calling, the one taking columns. What is the ndim_ in that case? It's the same value as the non-initialzed ndim_ which is holding garbage.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Scratch that I didn't uncomment the line. Hang on for a bit.

On line 63 change int to size_t so that the types match between the size() value and the index.

Also, definitely don't open your file each time through the loop move that open line up where the ostream is declared. That doesn't seem to be the issue however.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

myfile << data_[i+ndim_*j] << " "; should be myfile << data_[i+mdim_*j] << " "; Since you are jumping by a count of the number of rows each time you span a column. Do a quick "desk check" of it with pencil and paper to see.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm curious if it is the Event.h, why are some of the derived classes working and not others?

@OP: have you actually been able to employ the other derived classes in (working) code or was that just speculation?

I concur with Thomas, it couldn't at all hurt for us to have more of your code to test.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yea but this is for Visual Studio 2003 and I'm using 2008.

It's identical, I just checked it to make sure. Mine just says "Properties" on the project menu but I've seen it say "MyProjectName" Properties at points. Click on configuration properties on the sidebar of that window to get it to expand.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

you need {} in class train;

so it needs to be

class Train{};

No, that's a forward declaration. You don't need the braces. If you are going to use another class as an object in this class, that class must be defined first. However you don't need the full declaration you can "forward declare" it just so that the compiler knows it exists.

Also can you explain this bit here?

Arrival(int time, Train* newTrain);

This is a constructor for Arrival which takes two arguments, an integer and a pointer to an object of type Train (hence the forward declare before).

I don't know if this has anything to do with the problem at hand but when you define a constructor aside from the default one you have to explicitly define the default one. So you'd need: Arrival() {} amongst your public declarations (or you can implement something if you need a default behavior).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have a few other subclasses of Event and they aren't giving me any trouble.

How are their class declarations different from this one? I don't see anything in this one that's incorrect.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well you need to put a cout << endl; within your outer loop at the end so that you get it each time you complete a row

for (outer loop over rows)
{
    for (inner loop over each star in the row)
        print the star

    cout <<endl; //now we go to the next line
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is your loop:

for (count = 0; count < input_1; count++)
{
     for (count = 0; count < input_1; count++)
        cout<< " * " <<endl;
}

Trace through your loop the way you have it, it's going
* (+newline)
* (+newline)
* (+ newline)
*
since you have an endl after each star. Your inner loop need to print the entire row of stars so keep endl out of it. Put 1 endl just outside of the inner loop so that you catch it each cycle (after a row is written) through the outer loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Move the endl in the for loops outside of the first one so it's only called once per row. Also, you don't verify that your input fulfills those criteria you just print it out. See this thread to get some idea of what's involved. If that's a lot, simply test whether then number is positive.

Also, please learn to use code tags:

[code]

//code goes here

[/code]
(just like HTML but with [] -- or just highlight your code and hit the

button in the toolbar).[code]
button in the toolbar).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
ofstream myfile (filename.c_str());

Gives you a C style string that the method wants (with a '\0' (null) terminus).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Rather than using setw why not just print the number of spaces you need:

+  (3 spaces, 1 character)
    +  (3 spaces, 1 character)
    +
  +++++ (4th line down print across no spaces)
    +
    +
    +

Adjust accordingly (it's not quite balanced but you get the idea)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I get the following in the output file:

Average of 0.3*x^2+0.9*x+4.7, on [2,-5.4] is 5.406Average of 5*x^3+6.3*x^2+x+0.4
, on [10.7,1] is 1964.41Average of -x^1-x+2, on [0,0] is -1.#INF

I can't reproduce any of the errors that you have stated. It prompted me for a file name it did not skip over that. This is what I had in main():

ifstream in;
ofstream out;
process(in,out);

A couple of other things. Rather than doing all the file operations in the function I'm assuming your instructor wants you to perform all the opening in main and then just pass in the ifstream and ofstream objects. Otherwise there's no point in passing them in since you start fresh in the function anyway. Also, your function is supposed to return an int but it doesn't seem like you're sure of what that int should be -- is it a success or failure indicator or something completely different?

Also, I had wanted to say it's really cool that you decided to join the site as a sponsor. I'm confident that it means a lot to Dani too. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, you're not needing any return value back in main() nor are you returning anything in the method so really you should use void.

Try to figure out where it's crashing. Either run it through a debugger or pepper your code with couts to watch its progress.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you don't know any of the values for the parameters you're not going to be able to solve the equations. If you don't have any of the parameter, do you have values for x1,x2,x3 and y1,y2,y3? Please tell us what you have been given.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
while(!in.eof())
    {
    in>>n;
    double * coeff = new double[n+1];
    for(int i=n+1;i>=0;i--)
        cin>>coef[i];
    in>>a>>b;
while(in >> n) //don't use .eof see "http://www.daniweb.com/forums/post155265-18.html"
{
   // so now we've got n do the allocation
   //instead of cin you need to use in
   for(int i = n+1;i>=0;i--)
         in >>coeff[n];      //we get the exact number of coeff we need
   in >>a >>b;
   //do the processing 
   //output results
   delete [] coeff;
}

Then your loop is all ready for the next line, it get's the next n, allocates again, does the processing you're in business.
(otherwise reading in all of the data at the same time would give you a 2d array with varying lengths in one of the dimensions which could get messy).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's nothing to delete in your code yet. However, you haven't specified a length for your array. Coeff should be a double * so you can have a line between 28 and 29, double * coeff = new double[n+1]; (since your polynomial has n+1 terms). Then at the end you call delete [] coeff;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Since none of the equations depend on each other at all you can solve it as 3 separate quadratic equations so either with a root finder or the brute force (-b+- sqrt(b^2 - 4ac)) /2a business.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was just going to add into my post hehe. If you want it to show the message box it has to be >= textBox.MaxLength (or just ==) because the box won't let you surpass the count.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

MaxLength is the constant that you should compare against. I think the comparison would be textBox1.TextLength > textBox1.MaxLength, but I tried it a few times and it looks like you don't need to do anything because once you're at the MaxLength it won't let you add anything more into the textbox anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Judging from the other replies I bet I misjudged what the OP wanted. Apologies.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check to make sure there are no excess spaces in either the nicks string or in the pizza_establishment one. I know it's a constant I saw your string schema up there. Otherwise print out the strings right before that point. Absolute worst case go through them both and get the ASCII for each character.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That button is still a valid button. When I put a web browser on my form there's nothing on there with it, the button must have been added along the way. Right click it and check the properties to see what the name is. Then to have your code activate it, run mybuttonname.PerformClick().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

char EmpName; Char holds exactly that: 1 char. Make it into a string.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So , is it means that software engineering will include programming ?

More than likely but like Salem said Software Engineering is going to teach programming as a means to an end and may teach important concepts independent of language. The overall picture will probably be more theoretical. That doesn't preclude you from taking more programming classes as electives or as part of a second major if that's allowed. You can always pick up more languages on your own or via an online course but it's more difficult to teach yourself SE because a lot of it is (more than likely) project driven. Check out the websites for programs that you are interested in they should tell you the requirements in excruciating detail.

Salem commented: Yes. +19
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use the button.PerformClick() method (fill in the name of your control for button).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

cost isn't initialized in that function. If you get to the else section of the if clauses then you won't assign cost and you will return garbage.