![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
undeclared identifier...
My stupid variables are declared.. this is retarded!
// located in Engine.h
class Engine
{
public:
bool b_mailFile;
bool b_xFile = false;
bool b_samFile = false;
bool b_upload = false;
};
// located in cpp file (that includes "engine.h")
bool Engine::ParseFunctionHeaders(std::string script[])
{
b_mailFile = false;
b_xFile = false;
b_samFile = false;
b_upload = false;
return true;
}could someone please shed some light on my stupidity issue? EDIT: YUP it was stupidity! i guess throwing a prototype of the function into the class declaration would have helped lol ![]()
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#2 |
|
Expert Programmer
|
New Problems
std::string Engine::LTrim(std::string trimString)
{
std::string temp = trimString.c_str();
for(int i = 0; i<= sizeof(temp); i++) //THIS LINE IS PROBLEM #1
{
if(temp[i] = ' ')
{
trimString = "";
for(int k = i+1; k <= sizeof(temp) - (i+1); k++) // THIS LINE
{
trimString += temp[k];
}
}
}
return trimString;
}for the code above im getting this warning. I understand the warning just cant follow appropriate steps to overcoming it. 1>c:\documents and settings\knowell\my documents\visual studio 2005\projects\sed\sed\sed.cpp(56) : warning C4018: '<=' : signed/unsigned mismatch 1>c:\documents and settings\knowell\my documents\visual studio 2005\projects\sed\sed\sed.cpp(77) : warning C4018: '<=' : signed/unsigned mismatch And below i have a stupidity problem.. it will not let me use a string for comparison! // PARSE HEADERS FUNCTION
bool Engine::ParseFunctionHeaders(std::string script[])
{
b_mailFile = false;
b_xFile = false;
b_samFile = false;
b_upload = false;
int scriptSize = sizeof(script)/sizeof(script[0]);
for(int i = 0; i <= scriptSize; i++)
{
if(script[i] == "")
break;
if(Trim(script[i]) == "MAILFILE" && b_mailFile == false)
{
i_mailFilePos = i;
b_mailFile = true;
}
else if(Trim(script[i]) == "MAILFILE" && b_mailFile == true)
{
//AddError("[LINE#" + (i+1) + "] ER1003 Multiple Instance (MAILFILE)");
}
// THE REST OF THE FUNCTION IS UN-NEEDEDand below it the error 1> ] 1>c:\documents and settings\knowell\my documents\visual studio 2005\projects\sed\sed\sed.cpp(102) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion) 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Ax=std::allocator<char> 1> ] 1> could be 'built-in C++ operator==(const char [9], const char [9])' 1> c:\program files\microsoft visual studio 8\vc\platformsdk\include\guiddef.h(192): or 'int operator ==(const GUID &,const GUID &)' 1> while trying to match the argument list '(std::basic_string<_Elem,_Traits,_Ax>, const char [9])' 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Ax=std::allocator<char> 1> ]
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#3 |
|
Expert Programmer
|
Ok i fixed my problem again by appending ".c_str()" to all "script[i]"
Sorry to waste space! I should have known this. EDIT: OH i still have the signed/unsigned warning issue!
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#4 | |
|
Hobbyist
Join Date: Sep 2005
Posts: 266
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
int scriptSize = sizeof(script)/sizeof(script[0]); Try this: #include <iostream>
#include <string>
int main ()
{
std::string moo = "This is a very big string.";
std::cout << "The string 'moo' contains \"" << moo << "\" and is " << sizeof(moo) << " bytes big." << std::endl;
} |
|
|
|
|
|
#6 | |
|
Hobbyist
Join Date: Sep 2005
Posts: 266
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Ah, crap... ignore me. Must be late.
OK, if you want some useful advice, how 'bout this: use a freakin' std::vector instead? |
|
|
|
|
|
#8 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#9 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I believe that's how the information is stored... you sure I'm wrong? At the lowest level, I could swear it's a wrapper for a linked list.
|
|
|
|
|
|
#10 | |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
nnxion:
Quote:
[edit:] since std::string supports arbitrary indexing, I doubt a linked list would be used... |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|