daviddoria 334 Posting Virtuoso Featured Poster

shuma -

Welcome to DaniWeb!

Here are a couple of tips to get you the answers you are looking for:
- Though we understand not everyone is fluent in English, please use proper English words. E.g. "plz" and "plzzzz" are not English words.

- Please do not "hijack" threads. That is, epicasian asked a question, and then you asked your own question as a reply to his question! You should start a new thread if you have a new question.

- Typically no one is going to help you without showing them what you have tried first. You'll have much more success here if you post some code saying "I tried to do this - but here is the problem I am having".

Good luck,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You never tell it how big ClassFreq should be, then you start accessing elements! It looks like you should do

vector <int> ClassFreq(numberOfClass);

but I'm still not exactly sure what you are trying to do, it seems like there may be a better way using stl functions.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Welcome to Daniweb!

First, please use descriptive titles. This will help you get answers faster as people will be intrigued by your title!

To answer your question, my suggestion would be not to use c++! I think you will have much better luck posting this question in the game development forum:
http://www.daniweb.com/forums/forum71.html

You should also include details about which types of games you are looking to develop (and examples of existing, similar games), what kind of background in programming you have, etc

Good luck,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Yikes, please don't use global variables!!

Here is my suggestion - take a step back away from the code and explain to us in English what you are trying to do. Maybe someone can then suggest an appropriate way to go about it.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I'm not exactly sure what is going on, but it looks like Form1 is in the PublishWizard namespace and you have not given a PublishWizard:: prefix or a "using namespace PublishWizard" when you try to reference Form1 in Utility.h

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I agree with first person on that part.

As for the undefined symbol, I don't see anything obviously wrong. Again, you have posted 160 lines where probably 10 would do - I really suggest stripping everything down in a separate folder/project (just empty constructors basically) to try to isolate where the problem is coming from.

daviddoria 334 Posting Virtuoso Featured Poster

Please post the smallest compilable code that will produce this error.

:)

This is not just for fun - the idea is that it gets you to isolate the problem and hopefully solve it on your own!

So you are indeed including Player.h, so now we need to see the contents of Player.h

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please post the smallest compilable code that will produce this error. "undeclared identifier" in this case probably means that you didn't include the header file?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Unfortunately I don't have answer to your question, but I have two suggestions
1) make a much more descriptive title - this will entice people to investigate your problem
2) Please use code tags. This makes the code that you post much more readable.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I wouldn't do everything in the constructor. I would make it more like this:

Search mySearch;
mySearch.SetText("This is the text I want to search in");
mySearch.SetSearchString("want");
bool found = mySearch.Search();

This way you also can use the result in the calling function.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Look into "exceptions" (throw and catch). It won't be a magic solution, you have to predict the run time errors. But it is better than nothing.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

.size() tells you how many elements are in the vector.

God Coder123 commented: Thanks Dave really appreciate the help :) +1
daviddoria 334 Posting Virtuoso Featured Poster

Yea that is one thing I never figured out why they didn't include! I think you have to do:

array.push_back(1);
array.push_back(2);
array.push_back(6);
etc

Annoying, but the flexibility you get once it is built is MUCH worth it.

daviddoria 334 Posting Virtuoso Featured Poster

That wasn't my solution, so I'll let Aranarth answer, but I can suggest that if you use an std::vector<int> instead of an array the syntax gets much lighter - that is yourArray.size() vs sizeof(yourArray)/sizeof(*yourArray)

daviddoria 334 Posting Virtuoso Featured Poster

Please try to pose your question in a concise form such that it can benefit others in the future. That is, ask a question about c++, not about your program.

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

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Does this help?

int RandomInt(const int MAX)
{
	//produce an int from 0 to MAX-1
	return rand() % MAX; 
}

Dave

daviddoria 334 Posting Virtuoso Featured Poster

-L (the path) tells it WHERE to look. -l (the libraries) tells it WHAT to look for.

daviddoria 334 Posting Virtuoso Featured Poster

Can you use a std::vector<list>?

Also I would be very careful with the name "list". If somewhere else std::list gets included, then you're going to have conflicts.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please try to make your titles and questions as abstract as possible. This way the "next guy" can search and find something usable. If you ask "How do I randomly select an element of an array?" that is much more reusable than "How do I make a horse finish first?".

Dave

daviddoria 334 Posting Virtuoso Featured Poster

getline() from iostream will do the reading and you should use ofstream to do the writing. Give this a shot. If it doesn't work, post a < 10 line demonstration of the problem.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I recommend you do some googling for "static libraries c++" and "c++ linking". Then, I recommend you build this program manually (without eclipse) using g++ and the -L and -l flags. THEN once that works, the only problem is doing it in the "language"/framework of Eclipse.

Good luck,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Take a look at sort() from <algorithm>

daviddoria 334 Posting Virtuoso Featured Poster

I downloaded it and built it. This produced 3 ".a" files (static libraries). I had to link the program to these libraries so that the symbols were defined. This is done manually with

g++ -l[library1] -l[library2]

(ensuring the library path is either on your LD_LIBRARY_PATH or you tell g++ with -L)

In Eclipse, surely you can set libraries to link to without needing this syntax.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Is your project set up to link to all 3 libraries that build with sparselib?

daviddoria 334 Posting Virtuoso Featured Poster
daviddoria 334 Posting Virtuoso Featured Poster

I guess it depends on the logic of the program. You may want to use Fbody's suggestion of a bool array because say the number you guess is greater than the secret number - you'd want to mark ALL of the number above the guess as "used" because you've already effectively guessed that whole range.

daviddoria 334 Posting Virtuoso Featured Poster

You should definitely look into using a std::vector<int> instead of an array of ints. You can push_back() each element so the vector will grow to accommodate the new guesses. You could also use an std::set instead of an std::vector to "automatically" tell if a number had already been guessed. If the size of the set doesn't change when you insert(), then the number was already in the set!

Let us know if you have problems trying any of this.

Good luck,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I am using KDevelop and I got the same error (/bin/sh: double: No such file or directory). I added this to the top of your code instead:

#define COMPLEX std::complex<double>

And it compiled and ran fine. It must be something wrong that we are doing with the -D syntax.

Good luck,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

What is the error you are getting? Can you provide the smallest compilable piece of code that will produce this error, along with sample input, expected output, and current output?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Looks like you have some extra braces scattered throughout. Also, to pass by reference you have to do:

void readThreeNumbers(float &number1,float &number2,float &number3);

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Also, there is no reason to use global variables here. Define number1,2,3 in main and then pass them by reference to the functions.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please post 'character.h'. I suspect something like this:

void Character::Character();

when it should be simply:

Character::Character();

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I'd use a std::vector<std::string> no matter how you plan to do the recursion.

daviddoria 334 Posting Virtuoso Featured Poster

In recursion you need a "base case". Here I guess the base case is the first line of the song. So your function should probably be called PrintAllPreviousVerses(int verse) and just call it recursively decrementing 'verse' by 1. This actually doesn't seem like an ideal case to teach recursion, but maybe I just don't know what I'm talking about :)

daviddoria 334 Posting Virtuoso Featured Poster

Please mark the thread as solved. It would also be nice to write a brief description of what you ended up doing to solve it so that the next reader can share your new knowledge.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

No no, it is definitely ok to reset that variable. The problem is that you have popped the whole stack, then you are trying to get the top() of the stack, which is not defined.

This code runs fine

#include <iostream>
#include <stack>
using namespace std;
int main()
{
    stack<int> number;
    int x=0;
    number.push(43);
    number.push(34);
    number.push(45);
    number.push(28);
    x=number.top();

 while(number.size() > 1)
{
        number.pop();
	x=number.top();
        cout<<x << std::endl;
    }
return 0;
}

I'll leave it up to you to figure out the logic to get all 4 items, since this only gets 3 :)

Good luck,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please try to get the problem to occur not in 350 lines, but instead something manageable like 20 lines.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You are not resetting x to number.top after the stack is modified. So what is happening is you are setting x to 28, then in the loop you are modifying the stack but simply outputting 28 over and over! You need to add a x=number.top() between the number.pop() and the cout<<x.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

One thing I see is that you are not checking the bounds of the movement - i.e.

void movedown(int x, int y)
        {
            x = x;
            y = y + 1;
        };

Should be something like:

void movedown(int x, int y)
{
  // x = x; //this line doesn't do anything, so it can be removed.
  if(y < maxY)
  {
    y = y + 1;
  }
};

Once you fix those, can you use a debugger to step though the code and tell us when the error occurs and what the error says?

Good luck,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Sure, just set a member variable before your destructor gets called, and reference that variable from the destructor.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You have to select "1" before you can select "2" and start adding elements - else the vector is not defined! I'd suggest getting rid of all of the cod that is not necessary, setting the inputs you can in the code, and posting the shortest compilable example of what is going wrong.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

'm' seems to be expecting to map a string to a map<string,string>, but you are trying to tell it to map a string to a string. "Problem is iterator inner" - can you be a lot more specific? Is there a compiler error?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

How is 'it' defined? Please provide compilable code that produces the problem so we can take a look.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

You'll have to show us the values of all of the variables you are outputting. One of them must have a new line character. If you can produce a compilable example that writes the 2 line file, we'd be happy to check it out.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

The function is defined in a namespace:

namespace scythe {
  
  /*! @cond */
  
  /* Forward declarations */
  double gammafn (double);

So you have to call it like this:

double k=scythe::gammafn(5.0);

It seems completely crazy to me that they do not include any examples!!

Good luck.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Here are a handful of explanations and possible solutions:
http://www.daniweb.com/forums/thread114299.html

daviddoria 334 Posting Virtuoso Featured Poster

You had me confused for a minute, but you have a classic mistake! Remove the semicolon at the end of the for statement:

i.e. change this

for (int count =0; count <= numberGrades; count++);

to this:

for (int count =0; count <= numberGrades; count++)

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Looks like you need to increment gradeCount[0] as you've done for 'A', but gradeCount[1] for 'B' etc, rather than gradeCount[0] each time.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I imagine the problem is how you are actually compiling it. You need to compile both countertest.cpp as well as counter.cpp. My guess is that you are only compiling countertest.cpp.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please be more clear. How have you defined str? Did you #include <string> ? Did you use std::string? What do you mean by "not working"?