daviddoria 334 Posting Virtuoso Featured Poster

stemiros,

Great! I'm glad it worked. This is a perfect exemplar of what I was talking about :) In the process of explaining your question in a way that others can understand, you clarified it to yourself and figured it out simultaneously!

Keep up the good work.

David

daviddoria 334 Posting Virtuoso Featured Poster

Sure thing - glad it's working. Please mark the thread as solved.

daviddoria 334 Posting Virtuoso Featured Poster

Well closer to what you had before would be a pointer gc object:

int* a = new int;
  GarbagePointer<int>* myGC = new GarbagePointer<int>(a);

but the syntax you had originally posted doesn't make sense - you can't instantiate a class of one type with an object of a different type!

daviddoria 334 Posting Virtuoso Featured Poster

This compiles for me:

int* a = new int;
  GarbagePointer<int> myGC(a);

And it makes sense given this constructor:

explicit GarbagePointer(T* p = NULL) : value(p) { next=this;prev=this;
    };
daviddoria 334 Posting Virtuoso Featured Poster

Where does the problem occur?

daviddoria 334 Posting Virtuoso Featured Poster

As far as I know you can only 'switch' on int types. CommandCStrngType is definitely not convertible to an int! You should just replace your switch statement with a big if/else if/else.

daviddoria 334 Posting Virtuoso Featured Poster

You may have better luck in the C forum.

daviddoria 334 Posting Virtuoso Featured Poster

It doesn't sound like this has anything to do with your game. Maybe you can make a short, compilable example of this lagging effect in a very general context that someone can take a look at.

daviddoria 334 Posting Virtuoso Featured Poster

You can use a vector instead of an array

http://programmingexamples.net/index.php?title=CPP/STL/Vector

It also has a bunch of cool operations built in (sorting, etc).

daviddoria 334 Posting Virtuoso Featured Poster

Shouldn't this

GarbagePointer<int> myGC=new int;

be more like

GarbagePointer<int> myGC=new GarbagePointer<int>;
daviddoria 334 Posting Virtuoso Featured Poster

You need to abstract the problem wayyy past "Monsters Inc". You should ask the question generally so it helps the most people. Here are some details and specifics:

http://daviddoria.blogspot.com/2010/05/problem-abstraction-helping-others-help.html

Maybe something more like "I have two objects and I want to transform them together" or something like that. You should also post the code that you have tried that did not work and explain what is going wrong.

David

daviddoria 334 Posting Virtuoso Featured Poster

Is it:

A)

group individ;

B)

group* individ = new group;

or

C)

Do_Your_Own_Homework();
daviddoria 334 Posting Virtuoso Featured Poster

Most of the revision control sites now have built in bug trackers. Github.com for example: https://github.com/blog/411-github-issue-tracker

The big projects I work on use Mantis.

daviddoria 334 Posting Virtuoso Featured Poster

This has gone on much too long. You need to read a c++ tutorial to understand parameters and arguments and then give it another shot. I don't understand how you can expect to write something in a language that you do not know? If I gave you a German/English dictionary and asked you to write an essay, of course you would not be able to do it. Here you are trying to write an essay in c++, but you don't know the language!

jonsca commented: Yes +5
daviddoria 334 Posting Virtuoso Featured Poster

Learn to trust the compiler! That says you are passing a string to readnumbers, but it is expecting nothing to be passed.

daviddoria 334 Posting Virtuoso Featured Poster

This doesn't make sense:

num = X1.readnumbers (string);

You have to pass it a variable:

string a;
num = X1.readnumbers (a);
daviddoria 334 Posting Virtuoso Featured Poster

No matching function call means the arguments you are passing are not what the function expects. In this case you are passing nothing () and you are supposed to be passing a string.

Void value not ignored means you are assigning the "output" of a void function to a variable.

num = X1.readnumbers ();

doesn't make sense if readnumbers() is void.

daviddoria 334 Posting Virtuoso Featured Poster

& means "pass by reference". There is no need for that here:

void KeyPad::disp_message_nums (string stringN)      
{
     cout << stringN << endl;
       
}
daviddoria 334 Posting Virtuoso Featured Poster

Just because you return them in a previous function doesn't mean the next function gets access to them. You have to pass those variables to these functions if you want to use them.

daviddoria 334 Posting Virtuoso Featured Poster

You need to enclose the function in braces:

double KeyPad::convert_words_to_nums(string stringN)
{
int num;
char yourChar, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v,w, x, y, z;

...

return something;
}
daviddoria 334 Posting Virtuoso Featured Poster

You have declared it as:

void readwords();

but defined it as

void KeyPad::readwords (string words);

These need to match.

daviddoria 334 Posting Virtuoso Featured Poster

It is the same problem as last time. You need to add (). Change

void disp_message_nums;

to

void disp_message_nums();
daviddoria 334 Posting Virtuoso Featured Poster

Look, if I take your code, compile it, and tell you everything to fix, no one wins. I wasted my time, you didn't learn anything, and no one else reading this likely learned anything. If you give it a shot and try to read the error the compiler gives you and then ask us specific questions if you get stuck, that is a much better process.

daviddoria 334 Posting Virtuoso Featured Poster

You cannot call a function like this:

M2.disp_message_words;

You have to call it like this:

M2.disp_message_words();
daviddoria 334 Posting Virtuoso Featured Poster

I'm not familiar with Bloodshead, but my guess is that your files are either not in the same directory or you need to set your INCLUDE_PATH to include the current directory (.) (which should definitely already be set).

Also, you should never include a .cpp file

#include "implement.cpp"
daviddoria 334 Posting Virtuoso Featured Poster

Is KeyPad.h the name of the first code snippet you posted (where you said "Here is the class") ? Is this in the same directory as the rest of the files? Are you using Visual Studio?

daviddoria 334 Posting Virtuoso Featured Poster

Ok, let's start with the first one. Usually one or two errors at the beginning cause "lots" of other errors that are not actually themselves additional errors but the compiler gets confused and reports a lot more than is necessary to fix the problem.

daviddoria 334 Posting Virtuoso Featured Poster

It seems reasonable. What is the problem? Does it not work correctly? Are there compiler errors?

daviddoria 334 Posting Virtuoso Featured Poster

What I mean is that you should have a function called input() that you can change to either return hard coded values or actually accept input from the user from the keyboard. Then you can carry on testing your code without having to type inputs each time. When you are convinced it is working properly, then you can add back the actual input (cin) commands.

Also, height should be feet*12 + inches instead of just feet*12, right?

daviddoria 334 Posting Virtuoso Featured Poster

1) What is the problem? Does the compiler produce errors? Does it not work as you would expect? What is your input, expected output, and current erroneous output?

2) I always suggest separating the computation from the user interaction. Hard code some values and get the algorithm working before you get the input from the user. This will help eliminate a source of errors as well as make it quicker for you to debug (you don't have to keep typing in numbers to try it out).

3) Something like this: const double meter = 0.0254; should have a much more descriptive name. Maybe "metersPerInch" or something like that.

Good luck,

David

daviddoria 334 Posting Virtuoso Featured Poster

Of course that won't work both ways - you have only written one way :)

Also, it doesn't look like you've written anything to read a dictionary file, but you can certainly do so if you wish.

There are some IO examples here:
http://programmingexamples.net/index.php?title=CPP

daviddoria 334 Posting Virtuoso Featured Poster

This

2=(a||b||c);

is not valid c++ syntax. You should look up conditional (if) statments:

if( yourChar == a || yourChar == b || yourChar == c)
{
  // do something with number '2'
}

This tutorial is excellent:
http://www.cplusplus.com/doc/tutorial/

I suggest you start there.

David

daviddoria 334 Posting Virtuoso Featured Poster

Great, it works. A bit awkward/annoying, but it works :) Why do you say "this isn't the best way to do things"?

daviddoria 334 Posting Virtuoso Featured Poster

Where is php.ini? I only have ftp access to this server, so I doubt I can change (or even see) that file. Is there anything else I can do?

daviddoria 334 Posting Virtuoso Featured Poster

I am trying to include a file 'header.php' that is in

http://ewh.ieee.org/r1/schenectady/

From a file in
http://ewh.ieee.org/r1/schenectady/Events/

if I do:

<?php include '../header.php';?>

it works fine, as expected. However, if I do:

<?php include 'http://ewh.ieee.org/r1/schenectady/header.php';?>

it does not work (the header is not displayed).

Can anyone explain why this wouldn't work?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

When I get an email notification of a second+ reply to a thread, GMail collapses way too much of the email.

http://www.rpi.edu/~doriad/daniweb.jpg

The main thing that is missing is the link to the thread! (Of course I find it if I click "show quoted text". Is this a gmail setting? Or there is something that can be done to prevent this from happening on the DaniWeb side?

David

daviddoria 334 Posting Virtuoso Featured Poster

Oh I see, it actually needs to 'echo' the text so that it creates the page with that line. Can I define $ROOT more "globally" so I can use it through many files?

daviddoria 334 Posting Virtuoso Featured Poster

And I can use that right in HTML?

<div id="sidebar">
<p/>
$ROOT = "http://ewh.ieee.org/r1/schenectady/";
<a href="something"><src="$ROOT . images/schdy.gif"></a>

?

daviddoria 334 Posting Virtuoso Featured Poster

That code doesn't run for me. It crashes on line 58 v[i][j]=x[i]*y[j]; which means either x, y, or v isn't big enough.

daviddoria 334 Posting Virtuoso Featured Poster

Once you fill in some of the definitions of those functions, we'll be able to help you. This is just a very very high level outline.

daviddoria 334 Posting Virtuoso Featured Poster

I don't think the conditional on HYS_GLOBAL_VARIABLES is necessary because it is true in exactly the same case that the outer HYS_MAIN_HEADER_H is true. Also, why are you including those windows.h files?

daviddoria 334 Posting Virtuoso Featured Poster

@rch1231

This is the site:

http://ewh.ieee.org/r1/schenectady/

I only have ftp access, and it seems like '/' is where my index.php is. I don't see a httpd.conf, so I'm assuming its at a location "above my pay grade"? Since it seems like the problem is that '/' is not what we expect, could I make a variable:

ROOT = http://ewh.ieee.org/r1/schenectady/

and then include the images like:

ROOT/images/image.jpg

?

@Arkinder
The problem is that since this page (sidebar.php) gets included from different levels of the directory structure, hard coding ../images/image.jpg versus simply images/image.jpg is not an option, because the correct relative path is different based on where sidebar.php was included from.

daviddoria 334 Posting Virtuoso Featured Poster

Is there a reason you're writing your own list class instead of using the one in the STL?

http://programmingexamples.net/index.php?title=CPP/STL/List

daviddoria 334 Posting Virtuoso Featured Poster

I have a sidebar.php which contains:

<a href="page.html"><src="images/MyImage.gif"></a>

If I do:

<?php include 'sidebar.php';?>

from a file that is in '/', everything works properly (because it looks in /images for the gif).

However, if I do:

<?php include '../sidebar.php';?>

from a file in, say, '/Example', the image is not displayed.

After some searching I found that I could supposedly add a '/' to the beginning of the path:

<a href="page.html"><src="/images/MyImage.gif"></a>

but when I do this the image does not display in EITHER case.

Any thoughts?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

You should listen to the compiler :) 'hostshort' is indeed not declared anywhere in the code you've shown us.

daviddoria 334 Posting Virtuoso Featured Poster

Are you sure its supposed to be capitalized? The name of the header is 'mysql', so I would try mysql *conn;

daviddoria 334 Posting Virtuoso Featured Poster

As I mentioned in your other thread:

I suggest you make a compilable program no longer than 25 lines that demonstrates the issue. You should also put output statements at every place possible inside 'inttohex' so you can see exactly where it is going wrong. You should also do the calculation by hand so you can check the values along the way.

daviddoria 334 Posting Virtuoso Featured Poster

No problem, glad it's working. I hope you see the process a little bit though - break up the problem into the absolute smallest pieces you can. Often that will lead exactly to the solution.

Please mark the thread as solved.

daviddoria 334 Posting Virtuoso Featured Poster

Haha yea now I see it :) (kuromiyaruka, this is the kind of explanation that should definitely be in your original post!)

daviddoria 334 Posting Virtuoso Featured Poster

Is this a "visual studio" list box? (I'm not even sure of the terminology). Can you send a link to the documentation page of the list box? Surely there is a function to do this.