NathanOliver 429 Veteran Poster Featured Poster

If you want to store an object in a hash map then you need to create a hashing function that will convert the object into a hash value.

NathanOliver 429 Veteran Poster Featured Poster

No

NathanOliver 429 Veteran Poster Featured Poster

What are you expecting it to do?

NathanOliver 429 Veteran Poster Featured Poster

You are missing a < in between "\t" and program. Change line 19 to cout<<name<<"\t"<<rollno<<"\t"<<program<<endl; and you should be okay. Now all that's left to do is make your code standard compliant. What compiler are you using?

NathanOliver 429 Veteran Poster Featured Poster

If you name has a space in it then you need to use getline() and not >>. You need to make sure that you "flush" the input stream if you do a call to >> and then use getline()(mixing input operations)

NathanOliver 429 Veteran Poster Featured Poster

So what seams to be your issue? No one is going to just answer this for you.

NathanOliver 429 Veteran Poster Featured Poster

No because that would be giving the OP correct code and I am not going to help he OP with there homework since the OP provided nothing but the problem statement. I am pretty sure you could do a google search and see what a correct piece of code looks like.

NathanOliver 429 Veteran Poster Featured Poster

Suzie I did some checking and it looks like load_gif_external() uses ImageMagick or GraphicsMagick's external tools. save_gif_external() does not say that it does but you would think the load and save use the same mechanics.

NathanOliver 429 Veteran Poster Featured Poster

You should be able to zip it and upload the zip file. I think .txt files are not allowed.

NathanOliver 429 Veteran Poster Featured Poster

What is the file type?

NathanOliver 429 Veteran Poster Featured Poster

dinad578 did you just copy rubberman's code?

NathanOliver 429 Veteran Poster Featured Poster

So many bad things in that code. #include<iostream.h> and #include<conio.h> are not standard. void main() is not standard as well. main() should only ever return an int. clrscr() is not portable. Why do you have an array of 10 for 5 values?

NathanOliver 429 Veteran Poster Featured Poster

you have vData included in multiple files so you are getting a multiple redefinition error. You can only have 1 vData in the global scope

NathanOliver 429 Veteran Poster Featured Poster

Show your source code.

NathanOliver 429 Veteran Poster Featured Poster

You have already asked this question. Just re-posting it will not get people to do your homework for you.

NathanOliver 429 Veteran Poster Featured Poster

Why are you not able to use ifstream? If this is c++ code then either fstream or ifstream is what you need to use to read data from a file. Is this supposed to be C code?

NathanOliver 429 Veteran Poster Featured Poster

what is the number 45 21? What should the putput be when you enter 45 21?

NathanOliver 429 Veteran Poster Featured Poster

You are running out of the bounds of the array using i<=4 in your for loop. if(arr[i]>(arr[i+1])) will also run out of bounds when you are at the end of the array. You also don't want the print to be in the loop since it would print every time it finds a larger element. The most common way of findind the max of an array is as follows (pseudocode):

array a = {23,38, 81,12}
int max = a[0]  -- set max to the start of the array

for i = 1 to i < 4  -- start position 1 since you already have a[0] in max
{                   -- use < size of array and not <= since arrays are 0 index based
    if (a[i] > max)
        max = a[i]
}

display max
NathanOliver 429 Veteran Poster Featured Poster

What does your file data look like? What should it look like after decrypting?

NathanOliver 429 Veteran Poster Featured Poster

Have you ever worked with iterators? Using iterators you could do code like this.

typedef vector<double> C1DArray;
double sum(C1DArray::iterator it, C1DArray::iterator end)
{
    double sum = 0;
    while(it++ != end)
        sum += *it;
    return sum;
}

int main()
{
    C1DArray data;
    for(int i = 0; i < 30; i++)
        data.push_back(i);

    cout << sum(data.begin() + 4, data.begin() + 24);
    cin.get();
    return 0;
}
NathanOliver 429 Veteran Poster Featured Poster

AFAIK int a = 10; will allow the compiler to directly construct a with the value of 10 where as when you split it up the code still has to create a and then you have an additional assignment to assign 10 to it.

NathanOliver 429 Veteran Poster Featured Poster

When you open the HTML document in your browser does it show the image? Where is the image located relative to the HTML document? I have not used Qt but doing some basic googling it looks like you might need to use QTextDocument::loadResource to added images to the document.

NathanOliver 429 Veteran Poster Featured Poster

You have a reference member (highscore) in LavaLand and that needs to be initialized upon creation. Either remove the reference or change the constructor to take in a value to initialize highscore.

NathanOliver 429 Veteran Poster Featured Poster

Look at your constructor versus my constructor.

NathanOliver 429 Veteran Poster Featured Poster

If you want LavaLand to have a default generated constructor then you need to get rid line 8 in LavaLand.h. You could also just change line 8 to LavaLand() {}; to make a default constructor yourself.

NathanOliver 429 Veteran Poster Featured Poster

Why is a captian a singleton? Are there not multiple captains in the world? If you want to make a singleton then you need to follow the correct syntax. Here is an example of a singleton:

class Singleton
{
public:
    // this is a lazy evaluated singleton
    Singleton GetInstance()
    {
        static Singleton instance;
        return instance;
    }
private:
    Singleton() {};  // code for constructor goes here
    // make sure these are here to stop the object from being copied
    Singleton(const Singleton &);
    void operator=(const Singleton &);
}
NathanOliver 429 Veteran Poster Featured Poster

Why on earth would you return a string from this function and not take strings? A char * can be converted to a string so you should use strings. Does this code even compile? I'm not sure what compiler ou are using but line 16 should not compile.

I'll help you out and give you the pusedo code of how this should work if you want to see how to do it with char *'s. I am not putting any error checking in it.

int new_string_size = orig_size + new_sub_size - old_sub_size
char * new_string = new char[new_string_size]

// copy first part of original
for i = 0, i < index_of_substring_to_replace; i++
    new_string[i] = orig[i]

for j = index_of_substring_to_replace, k = 0; j < index_of_substring_to_replace + new_sub_size; j++, k++
    new_string[j] = new_sub[k]

// m is the index of orig after the sub string
for l = index_of_substring_to_replace + new_sub_size, m = index_of_substring_to_replace + orig_sub_size; l++, m++
    new_string[l] = orig[m]
NathanOliver 429 Veteran Poster Featured Poster

Well you can have the StoneAdventure class hold a vector of rooms and then you can declare room to be a friend of StoneAdventure.

NathanOliver 429 Veteran Poster Featured Poster

Is it not working? It should work but I see you have the code commented out. Why is that? Here is a good reference for using sort.

NathanOliver 429 Veteran Poster Featured Poster

What is Error_code? Is the the enum type? Can you post your class?

NathanOliver 429 Veteran Poster Featured Poster

Really?!? A downvote because you can't come up with an answer?

NathanOliver 429 Veteran Poster Featured Poster

That's not going to happen. This is not a website where you post your problem and you get an answer. This is a place where you come to with questions about an answer and we will help you with it. You get what you put in. Putting in nothing gets you nothing.

Ivzirnalsradeys commented: i understand and sory +0
NathanOliver 429 Veteran Poster Featured Poster

There is no standard way in c++ to have an * replace a character while typing.

NathanOliver 429 Veteran Poster Featured Poster

Well that is pretty easy to do. You need to calls two >> and one call to ignore to eat the rest of the line. The folwwing is psuedo code:

column1, column2
// use ifstream for file read operations
ifstream file(some data file);
// since the first read operation in a line is >> use that for the loop control
while (file >> column1)
{
    file >> column2
    file ignore rest of line
    add column1 and column2 to some sort of container.
}

You can read here on how to ignore the rest of the line in the file.

rehan_5 commented: Thanks Alot.. +0
NathanOliver 429 Veteran Poster Featured Poster

You are running Visual Studio 2012 which is version 11. version 11 has little to no c++11 support. You need to go to version 2013 update 3 to get te best support that Microsoft offers.

NathanOliver 429 Veteran Poster Featured Poster

Are you using Visual Studio 2012? I don't know of a Visual Studio 12 unless you are talking about version 12. If you go to Help -> About you will get a window like the attached. Post it here.

NathanOliver 429 Veteran Poster Featured Poster

What compiler are you using? MSVS 2013 does not have an issue with it. Also if you want to intialize number with 4 using braces you would use int number{4};

NathanOliver 429 Veteran Poster Featured Poster

Move line 19 to be between lines 6 and 7.

NathanOliver 429 Veteran Poster Featured Poster

What? Isn't copy and paste a skill?

NathanOliver 429 Veteran Poster Featured Poster

@ melissad - What you poseted was not c call at all. fstream is from the C++ STL. Not sure if you noticed but your code will run forever or throw an exception for reading outside the bounds of the file or array. There is an error with the inner for loop.

NathanOliver 429 Veteran Poster Featured Poster

That means the the Polynomial class is going to have an array of terms the represent the polynomial.

NathanOliver 429 Veteran Poster Featured Poster

Whats is sqrt in modifiedExpr.replace(modifiedExpr.find(sqrt),sqrt.length(),"#");? Is it a string? You should be able to do:

string sqrt = "sqrt";
size_t pos = 0;
while((pos = modifiedExpr.find(sqrt, pos)) != std::string::npos)
{
    modifiedExpr.replace(pos, sqrt.size(), "#")
}
NathanOliver 429 Veteran Poster Featured Poster

You have:

bool Expression::IsOperator(char C)
{
    if(C == '+' || C == '-' || C == '*' || C == '/' || C == 'sqrt' || C == 'log' || C == 'abs' || C == '~')
    {
        return true;
    }
    else
    {
        return false;
    }
}

Which makes no sense. A char cannot be more then one letter. You need to replace the function calls with single characters before you pass them shuntingYard().

NathanOliver 429 Veteran Poster Featured Poster

@iamthewee The OP's function uses var and val. I don't think it would compile if they had the same name. I think that would be a type redeclaration error.

NathanOliver 429 Veteran Poster Featured Poster

If you need to be able to change a variable at any time why not store everything as tokens? Then the token for a variable can hold onto the variable and the value of it. When you read in the expression you would tokenize the string and create a stack, list or vector of tokens. Then you could change variables at any time.

NathanOliver 429 Veteran Poster Featured Poster

A=πr^2

NathanOliver 429 Veteran Poster Featured Poster

When the function exits are you updating the original expression to be the modified? If not then this will always happen. I think you need to store the modified expression in the class and when you first set the expression set the modified expression to be the same as the original. then whenever you call a function that modifies the expression use the modified expression.

NathanOliver 429 Veteran Poster Featured Poster

modifiedExpr = originalExpr; needs to be moved outside the loop. The way you have it now is every time the loop is executed modifiedExpr becomes the original again erasing what you just did.

NathanOliver 429 Veteran Poster Featured Poster

ruberman I would have to disagree that you have to learn C to learn C++. Saying C++ is C with classes really diminishes what C++ is. You have templates, exceptions, lambdas now, stronger type safety and a host of other features.

NathanOliver 429 Veteran Poster Featured Poster

Well if you have never used C++ you really should learn how to use it before you try to use it. Otherwise how do you know how to start coding the project. Have you programmed in any other languages? What is the project that you need to get done? Does it need to be console based or GUI? There are so many things you need to have mapped out before you even start writing code.