rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Better still, use a vector containing elements that are a structure that has the two (left and right) values. The vector can, depending upon your method of adding the data, can automatically resize itself. Then you can just iterate through the vector when you are ready to compute/transform/output etc.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You are starting to get a handle on what the process of "compilation" consists. How complex each of these steps are, depends on the language. Some, such as a simple calculator, will be very simple, and not too much code. Others, such as languages like C++, are infinitely more complex. Fortunately, you don't need to write one of those! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I assigned the values on line 19

Yes, but your terms were reversed. You should have done this: num[g] = numb;

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Look at line 19. Do you see the problem? numb = num[g];

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You analyze it and tell us... No help on school work from us until you have made a reasonable effort to solve the problem yourself. Also, please post code inside of code blocks. See the "[code]" button at the top of the message editor.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, that would be an unbalanced tree. A more balanced one would look like this:

Int
                Char              Float
            Case    Const   Double     Struct
       Break                                 While

The main thing about AVL tress is that no sub-tree can be more than one level deeper than its sibling. While yours is technically that, it may no exhibit a self-balancing state if you were to insert new elements. Then again, it might. I've written these in commercial code in the deep dark past for database indexing applications, but you haven't included any of your code to analyze for correctness.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Usually the suggestion is to use both pragma once and include guards, so that it is portable and also allows the possibility of compiler optimization. I just said include guards just because.

Indeed. #pragm directives are incredibly non-portable. You absolutely MUST guard them in all but possibly a few common cases. In fact, #pragma directives are specifically intended to allow different compilers and platforms to tweak behavior in very personal ways. They are definitely NOT intended for general programming use.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Part of your problem is this: void calcStats(playerInfo[], int, double, double); This is the declaration of the calcStats() function. However, where it is defined/implemented, the signature is this: void calcStats(playerInfo[], int, double&, double&); Since the two double& arguments are properly passed as references, so you can update them in the body of the function such that the caller gets the updated information, then you need to correct the declaration. These issues will result in either compilation or runtime errors and/or bugs. I'm sure there are more of the same sort of C/C++ newbie coding errors that I haven't taken the time to suss out, but I think you get my drift. Keep at it, and we'll look again later after you have cleaned up some of these things.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A structure keeps closely associated data together, kind of like a lump of similar stuff. Your professor wants you to start thinking about how data is associated together, and can be processed together. It simplifies your code, reduces bugs, and enables you to develop much more complex systems. The concept is that of "abstractions". In C++, these are classes (structures of data and associated behavior). For example, the class "Person" may have the following data elements: gender, age, height, weight, marital status, education, income... So, and array of "People" can model groups, such as a club, race, residents of a town, members of a band, or whatever. Clear as mud, right? :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You have a long way to go... There a a number of graphical tools and API's available, many of which can run on most operating systems (Windows, Linux, Unix, Apple, etc). OpenGL is quite low-level and requires a great deal of detailed knowledge of the windowing environment (different on each platform) and of other technical issues. You will probable be better served with a more generic tool set, such as wx or Qt, to solve your display issues. If you are new to C++, Qt is probably the better choice for you.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This should probably be moved to the Java forum.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Read up on the file seeking functions. You can position your current read/write position at a specific place in a file, either offset from the beginning, end, or your current location (backward or forward) in the file. From the Linux fseek() man pages:

FSEEK(3)                   Linux Programmer’s Manual                  FSEEK(3)

NAME
       fgetpos, fseek, fsetpos, ftell, rewind - reposition a stream

SYNOPSIS
       #include <stdio.h>

       int fseek(FILE *stream, long offset, int whence);

       long ftell(FILE *stream);

       void rewind(FILE *stream);

       int fgetpos(FILE *stream, fpos_t *pos);
       int fsetpos(FILE *stream, fpos_t *pos);

DESCRIPTION
       The  fseek()  function sets the file position indicator for the stream pointed to by stream.  The new position,
       measured in bytes, is obtained by adding offset bytes to the position specified by whence.  If whence is set to
       SEEK_SET,  SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indica-
       tor, or end-of-file, respectively.  A successful call to the fseek() function clears the end-of-file  indicator
       for the stream and undoes any effects of the ungetc(3) function on the same stream.

       The  ftell()  function  obtains  the  current value of the file position indicator for the stream pointed to by
       stream.

       The rewind() function sets the file position indicator for the stream pointed to by stream to the beginning  of
       the file.  It is equivalent to:

              (void) fseek(stream, 0L, SEEK_SET)

       except that the error indicator for the stream is also cleared (see clearerr(3)).

       The  fgetpos()  and fsetpos() functions are alternate interfaces equivalent to ftell() and fseek() (with whence
       set to …
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The Linux kernel is written in C, and mostly does even handling (hardware and software interrupts, I/O events, CPU traps, etc). What precisely do you mean by "event handling"?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ok. That would be helpful. Writing operators can sometimes be confusing for the new C++ developer. The signature is critical. If you are using a non-const signature and are (probably) applying it to a const object, reference, or pointer, then you will have a problem. Likewise, the arguments passed and the return value matter.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, keep going... It's early to give up yet. :-) Just one comment. Test for the EOF indicator (999999999 999999999 values read in the file), which is the sign for "done reading". The question is whether you want to generate output as your read input, or wait until all input has been read, storing the values for later output. There are pros and cons for either approach, depending upon what you are trying to accomplish.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What dviddoria said, but also the GPU stuff requires 1) an nvidia card w/ CUDA capabilities, and 2) the nvidia CUDA development tools and libraries. This second issue is what may be causing your link failure. Anyway, here is the OpenCV GPU FAQ page which talks about what you need to do to use it: http://opencv.willowgarage.com/wiki/OpenCV%20GPU%20FAQ

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You still are not being very clear in what you are trying to do, so let me put on my pointy, star-covered wizard hat and see if I can read your mind...

You have been able to output random times and/or values to a string, but you want to do the same to a stream?

Ok. I give myself about a 2% likelihood of being in the ballpark. :rolleyes:

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I've seen poorly made cables short out like that. Glad you got it sorted.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can boot a Linux rescue CD/DVD and see if the drive is accessible or not. If not, then either the drive or the controller are fubar. If it is visible with the "fdisk -l" command, then it may be than something has munged the boot loader. There are several ways to fix that, including MS tools to restore the MBR (master boot record).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I think your surmise about a short circuit is likely correct. Check the cabling and connectors first, but it may well be that either the backlight is bad, or the display itself is fubar. My guess would be the backlight, but that is just a SWAG.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is a link to a page with a list of OpenSuse mirror sites. One may work better for you. http://mirrors.opensuse.org/list/all.html

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Some people here have actually earned their knowledge, positions, and degrees the hard way, by doing the work. I'm happy to see that you are not so inclined. After all that takes time and effort!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

No doubt, the easiest language to write a compiler for is Brainf*ck. Writing an interpreter for this language is probably gonna require less lines of code that the "Hello World" program in Brainf*ck.

ROFLMAO! I think it should be renamed to "Brain Fart"... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ok. It seems to me that your teacher wants you to think about how to parse some well-formed statements into tokens and a structure that allows you to further evaluate them. There are several key steps you need to implement:

1. Reading the input and breaking it into separate pieces (called tokens or symbols).
2. Organizing the symbols into some sort of structure (such as a tree or list) that makes evaluation of them possible.
3. Evaluating the structure and symbols it contains to obtain a result.

So, the thing is to start you thinking about data structures and algorithms. As the title of Niklaus Wirth's (the inventor of the Pascal and Modula languages) seminal CS text book states "Algorithms + Data Structures = Programs". :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

OK, I can see that. I personally prefer using C/C++ terms for programming concepts rather than math terms when talking about programming. Less confusion. But that's just me.

Yeah. I can relate. Even my wife, a particle physicist, calls me an uber geek!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

1. The type empname does not exist. It is 'emp'. The variables empname, empid, etc are part of the class emp. You need an instance of 'emp', where you can get/set empname, empid, etc.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

First, we need to know exactly what error you're getting and where the error occurs. Don't leave it to us to read and understand all 181 lines of code -- pinpoint the problem for us.

And rubberman, argv is not a vector but an array of char* -- but you probably knew that...

Arrays are analogous to the mathematical concepts of the vector, the matrix, and the tensor. Indeed, arrays with one or two indices are often called vectors or matrices, respectively. Arrays are often used to implement tables, especially lookup tables; the word table is sometimes used as a synonym of array.

I meant vector, which is actually what the 'v' part of argv is short for... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Now, show what you did to compile and link this program.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Post the contents of your .cvsrc file here. From the Linux CVS man page:

-f

         Do not read the ~/.cvsrc file.  This option is most often used because of the non-orthogonality  of  the  cvs
         option set.  For example, the cvs log option -N (turn off display of tag names) does not have a corresponding
         option to turn the display on.  So if you have -N in the ~/.cvsrc entry for log, you may need to  use  -f  to
         show the tag names.
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I used to teach relational algebra and calculus, but this was before Tutorial D came along (mid 1980's). What system are you using, D4?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You make an effort to solve your class problems, and then we will consider helping you through some of the rough spots. Don't expect us to do your work for you. It isn't fair to you (you learn nothing), and it isn't fair to the others in the class who are making an effort. Try using Google or Wikipedia. Amazing what you can find on the internet.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So, what does this code have to do with class diagrams (the subject of the post)?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

DO NOT ASSIGN VALUES to the vector argv[] (lines 27, 77, etc). Those are set by the system when the program runs. You have probably munged program memory as a result.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Not too helpful. Please post the error messages here.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Even though it is a memory hog, the way that Chrome handles each tab/window by forking another process is a major clue to its stability. If something crashes a web page, only that page is fubar. All the other open pages will remain intact. Also, that keeps malware that might be embedded on one page from infecting another, since each page is effectively sandboxed.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is why we have virtual machines. My advice to newbies to Linux is to install something like VirtualBox on their Windows system, load Linux into a virtual machine, and get used to it that way first. Either that, or if they really want to run Linux on their system, but still have use for Windows, then I have them do a Wubi install of Ubuntu.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What version of RHEL are you running? 4, 5, 6? In any case, the process is this.

1. Login as root
2. cd to /etc/yum.repos.d
3. Remove red hat specific .repo files.
4. Copy CentOS or Scientific Linux repo files to /etc/yum.repos.d
5. You should be done, except to install/update your packages

I ask what version you are running because I have the repos for CentOS 5 as well as SL6. I can get the repos for you for SL back to version 3, but if your RHEL system is that old, you would be well advised to update pdq.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Yea i all ready did the SRS pseudo code and data flows. The thing is i was never taught how to do the documentation of user guides detailed designs and test plan documentation. Was just asking for some good templates

Ok. Then you are most of the way there. There are open source projects that have decent user manuals that you should look at, and the Software Project Survival Guide mentioned should be helpful. Here is a set of Google search terms that will bring up a number of user manual templates you can download and/or use: software user manual template

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Also, coding first then writing the specs and other documentation is bass-ackward! Gather requirements, write specifications (use-cases), design the system (class model, relationship diagrams, pseudo-code, scenarios, state machines, etc), write user document, develop test plan, write code, execute test plan, update documentation for changes made while coding/testing, and track the fulfillment of the requirements - what code artifacts are related to which requirements.

By the time you get to coding, 90% of the work has been done, you have a clear understanding of what the system is going to do, and how it will do it. As a result, you will finish the coding and testing phase much faster, and are likely not to encounter any major need to redesign, which is what gets you into major time trouble on a project like this.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Consider this an exercise in parsing, more than anything else. Also, write out the process to use with pseudo code before you start to write any C code. So, here is a brief p-code version of what a shell does

const char* progname = 0;
while not done
    read line
    do
        eat white space
        read word
        if (progname is nil) set progname to word
        else add word to arglist
    while not end-of-line
    if (progname is not nil) /* We have a command to execute */
        if (progname is "exit") /* Done with shell */
            done = true;
        else
            use path environment and progname to find program file to execute
            if program file found
                if ((pid = fork()) == 0) /* We are in child */
                    status = execvp(progfilename, arglist);
                    /* Any status return means execvp() failed - see errno */
                else if (pid > 0) /* We are in parent - wait for death of child */
                    waitpid(pid, 0, 0);
                else if (pid == -1) /* Error forking - see errno */
                endif
            else
                /* Command file not found */
                /* Check for and execute internal commands if implemented */
            endif
        endif
    endif
end-while-not-done

As you can see, this has set out the steps we need to do in order to have a functioning shell. Of course, the devil's in the details, but until you have your thinking and processes in order, you are wasting your time. And in case you are interested, I wrote my first shell in C about 30 years ago.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Monte Carlo methods are used for complex simulations. It is widely used in particle physics for designing experiments. Here is a link to a web site at Oak Ridge National Lab on numeric algorithms and monte carlo methods that may be of help: http://www.phy.ornl.gov/csep/CSEP/BMAP.html

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

That makes sense, you're right, thanks. The first part, I mean (re: Sales). I don't know what you mean about "the output from printStock()"? Explain further?

Your code

void printStock (int v[], int n) {
	for (int i=0; i<n; i++)
		cout << i << v[i];
	return;
}

Has no space between the output of the variable 'i' and the value of v. For readability, something like this may be better:

void printStock (int v[], int n) {
	for (int i=0; i<n; i++)
		cout << i << " " << v[i] << endl;
	return;
}

That will put a space between the index 'i' and the value 'v', as well as placing each entry on a separate line. In your example, you would just have a single line, with the index and values all jammed together, such as:

010111212313...

Not particularly helpful, IMO.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

When sales() returns a double, why are you computing and returning an integer?

Also, look at the output from printstock(). You are concatenating i and val, which at best is confusing for the viewer. I haven't got to main() yet...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In any case (continuing from my previous comment), the file c.cpp seems to have an error in it. However, since you do not provide the code, there isn't much that we can say about what the problem is.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

the screenshot it posted WAS the error output.
and it was a v simple hello world program, with iostrem as the only lib. its on iphone OS, but jus tell me whats wrong, according to the output..

Sorry, but it was a link, not an embedded image. I generally do not navigate to those as they are often the source of "drive by" virus attacks...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Yes, well your example is treating a char as an integer, which it is (a really short one). That really isn't what the original question was about, as far as I could see. It seemed to be about converting a character representation of a number (a string) to a real number, hence the comments about using atoi(), stroul(), etc. Next time, be more precise.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

How exactly is this an obvious question?

Who asked you to write my program for me?

This is a specification and it must be met. The function head has a char, so I must pass a char, not a char *.

Well, atoi() and the rest do NOT take char types. They take const char* types. You can pass an array of chars, but that is just the same as a pointer.

Anyway, I have been doing this for 30+ years. Don't try to teach your grandmother how to suck eggs!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What OS and compiler are you using? And what command(s) did you use to build your code? Finally, please post the error output you got, as well as the code if possible.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Are you talking about running an OS in a virtual machine? If so, then read this first: http://en.wikipedia.org/wiki/Virtual_machine

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Actually, your constructor is very badly written - I give it an 'F'. More properly it should be like this:

myclass::myclass(const myclass &obj)
: p(new int)
{
 *p = *(obj.p); // copy value
 cout << "Copy constructor called.\n";
}

Note the instantiation of the pointer member in the initialization block before the body of the constructor itself. Also, note the parens scoping the copy and member p when dereferencing it. If you said *p = *obj.p; you have to ask yourself whether the *obj.p means dereference obj, or dererence the p member of obj. If for some reason obj was a pointer, then it would have meant (*obj).p which would result in the address of p, not the value contents of p.

My point in all of this is that you need to be very careful in C++ to code EXACTLY what you mean and intend. Don't make assumptions, but understand precisely what you mean. C++ is a very precise language, and failure to incorporate that precision in your code is just asking for a lot of really nasty bugs to reside therein.