Question about 'saving'

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 2514 Views - Last Post: 05 June 2010 - 11:30 AM Rate Topic: -----

#16 Cyrusthebeast   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 11-October 09

Re: Question about 'saving'

Posted 04 June 2010 - 09:34 PM

View Postjanotte, on 04 June 2010 - 08:28 PM, said:

View PostCyrusthebeast, on 05 June 2010 - 01:20 PM, said:

Quote

no suitable conversion function from std::string to int exists


But as I said before, I'm not trying to convert it.


Yes you are.
Look at your prototype for this function:
void vLoad(int Name, int Gender, int Order, int Strength, int Health, int Mana, int Defense, int Chapter, int Level);


What type is expected for the first argument?
What type are you passing in?


Ah! That's how it let me compile the first time, but then I get the errors I mentioned a few posts ago (I'll repost them):

Quote

1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(9): error C2065: 'string' : undeclared identifier
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(9): error C2146: syntax error : missing ')' before identifier 'Name'
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(9): error C2182: 'vSave' : illegal use of type 'void'
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(9): error C2059: syntax error : ')'
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(10): error C2065: 'string' : undeclared identifier
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(10): error C2146: syntax error : missing ')' before identifier 'Name'
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(10): error C2182: 'vLoad' : illegal use of type 'void'
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(10): error C2059: syntax error : ')'
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(15): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(37): error C2064: term does not evaluate to a function taking 9 arguments
1>c:\users\cyrus\documents\visual studio 2010\projects\game\main.cpp(46): error C2064: term does not evaluate to a function taking 9 arguments

Was This Post Helpful? 0
  • +
  • -

#17 Oler1s   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1397
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Question about 'saving'

Posted 04 June 2010 - 09:41 PM

Look at your placement of using namespace std;. It's below the function declarations. Either move the using declaration up, or qualify the types as std::string, etc.

You need to learn to read errors, and make logical deductions from that.

error C2065: 'string' : undeclared identifier Why would this happen? 1) Didn't include <string>, so compiler doesn't know about it. 2) Didn't have using namespace std; before using string.

How can you reach those above conclusions? You should know about two things. The first is that you must declare types before using them. The second is that they must be qualified appropriately. For example, all standard C++ types live in namespace std. So they must be qualified with std::, or you must have a using declaration. Similarly, the headers contain the type declarations.

Don't shrink back from errors.
Was This Post Helpful? 0
  • +
  • -

#18 Cyrusthebeast   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 11-October 09

Re: Question about 'saving'

Posted 05 June 2010 - 10:29 AM

View PostOler1s, on 04 June 2010 - 08:41 PM, said:

Look at your placement of using namespace std;. It's below the function declarations. Either move the using declaration up, or qualify the types as std::string, etc.

You need to learn to read errors, and make logical deductions from that.

error C2065: 'string' : undeclared identifier Why would this happen? 1) Didn't include <string>, so compiler doesn't know about it. 2) Didn't have using namespace std; before using string.

How can you reach those above conclusions? You should know about two things. The first is that you must declare types before using them. The second is that they must be qualified appropriately. For example, all standard C++ types live in namespace std. So they must be qualified with std::, or you must have a using declaration. Similarly, the headers contain the type declarations.

Don't shrink back from errors.

So simple! Sorry again XD I just sort of assumed that because I put using namespace std; at the top of the functions.cpp file it would work, without reading up on Forward Declaration as much, I didn't realize that all that does is show the compiler that it's there, not where it's at XD

Is there a really good place to look up lots of errors for C++?
Was This Post Helpful? 0
  • +
  • -

#19 Oler1s   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1397
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Question about 'saving'

Posted 05 June 2010 - 11:21 AM

Quote

I didn't realize that all that does is show the compiler that it's there, not where it's at
I have no idea what this sentence is supposed to mean, but I highly doubt you understand the problem. The compiler reads top down. If you have a using declaration, it only applies to: (1) whatever follows, after the declaration, and (2) the scope. It's the same reason you can't have: x= 5; int x;. Top down, left to right reading of statements.

Quote

Is there a really good place to look up lots of errors for C++?
Google and compiler references. That said, you need to learn to solve errors by problem solving, not by memorizing. The errors communicate problems in plain English. You need to work backwards and determine possible causes.

Note that my post didn't talk about looking up the error. You can, of course, do this by typing "error C2065" into Google, which leads you to more posts, and MSDN documentation with examples on what causes the error. But I didn't even bother talking about looking up errors, because I figured you weren't even reading the errors.

How do I make this accusation? Because you never pointed to an error. You didn't talk about: error C2065: 'string' : undeclared identifier which is the first error you received. You never put forward reasons why you think string should be considered declared beforehand. You indicated nothing to suggest you were tackling the problem error by error.

Did you research what causes undeclared identifier. For example, if I type into Google, that very error message (copy paste), the first result gives information that suggests points to consider. The first is to qualify as std::string. The second is to consider position, and replies in that gamedev thread actually have code examples. You discussed neither in your question here.

As a programmer, you solve problems. That involves typing code and also involves resolving errors. Debugging and isolating errors is critical. These are simple problems. You can just type into Google and get answers.

Your problems will increase in complexity. You will have runtime problems, not compile time problems. You will have harder test scenarios. You will have heisenbugs, and other hard to reproduce bugs. What's critical to handling them is a practiced problem solving approach.

Your approach when dealing with errors is to dump them here and ask for the solution. How far do you think this will carry you?

This post has been edited by Oler1s: 05 June 2010 - 11:22 AM

Was This Post Helpful? 0
  • +
  • -

#20 Cyrusthebeast   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 11-October 09

Re: Question about 'saving'

Posted 05 June 2010 - 11:30 AM

View PostOler1s, on 05 June 2010 - 10:21 AM, said:

Quote

I didn't realize that all that does is show the compiler that it's there, not where it's at
I have no idea what this sentence is supposed to mean, but I highly doubt you understand the problem. The compiler reads top down. If you have a using declaration, it only applies to: (1) whatever follows, after the declaration, and (2) the scope. It's the same reason you can't have: x= 5; int x;. Top down, left to right reading of statements.


Well I learned about forward declaration from here:

http://www.learncpp....d-declarations/

Quote

Consequently, a better solution is to use a forward declaration. In a forward declaration, we declare (but do not define) our function in advance of where we use it, typically at the top of the file. This way, the compiler will understand what our function looks like when it encounters a call to it later.


So I just sort of figured that it tells the program that the function is there but doesn't go find it to know that where the function is has the standard namespace in use.

View PostOler1s, on 05 June 2010 - 10:21 AM, said:

Quote

Is there a really good place to look up lots of errors for C++?
Google and compiler references. That said, you need to learn to solve errors by problem solving, not by memorizing. The errors communicate problems in plain English. You need to work backwards and determine possible causes.

Note that my post didn't talk about looking up the error. You can, of course, do this by typing "error C2065" into Google, which leads you to more posts, and MSDN documentation with examples on what causes the error. But I didn't even bother talking about looking up errors, because I figured you weren't even reading the errors.

How do I make this accusation? Because you never pointed to an error. You didn't talk about: error C2065: 'string' : undeclared identifier which is the first error you received. You never put forward reasons why you think string should be considered declared beforehand. You indicated nothing to suggest you were tackling the problem error by error.

Did you research what causes undeclared identifier. For example, if I type into Google, that very error message (copy paste), the first result gives information that suggests points to consider. The first is to qualify as std::string. The second is to consider position, and replies in that gamedev thread actually have code examples. You discussed neither in your question here.


Well as I said, it was just a misunderstanding of the forward declaration. In the functions that I declared forwardly (or however you say it), the standard namespace was in use, so it confused me.

View PostOler1s, on 05 June 2010 - 10:21 AM, said:

As a programmer, you solve problems. That involves typing code and also involves resolving errors. Debugging and isolating errors is critical. These are simple problems. You can just type into Google and get answers.

Your problems will increase in complexity. You will have runtime problems, not compile time problems. You will have harder test scenarios. You will have heisenbugs, and other hard to reproduce bugs. What's critical to handling them is a practiced problem solving approach.

Your approach when dealing with errors is to dump them here and ask for the solution. How far do you think this will carry you?


If you look between posts, I get a decent amount done, starting with basically just hello world knowledge and turning it into this with just a few questions is an achievement (at least to me), I've been learning a lot about it. I admit I could have looked harder but it was just confusing and didn't make sense to me because I was using the standard namespace in functions.cpp. :|
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2