Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 22nd, 2006, 10:38 AM   #1
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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
Kilo is offline   Reply With Quote
Old May 22nd, 2006, 10:55 AM   #2
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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-NEEDED

and 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
Kilo is offline   Reply With Quote
Old May 22nd, 2006, 11:07 AM   #3
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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
Kilo is offline   Reply With Quote
Old May 22nd, 2006, 1:11 PM   #4
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 266
Rep Power: 4 Cache is on a distinguished road
Quote:
Originally Posted by Kilo
	//...
	for(int i = 0; i<= sizeof(temp); i++)  //THIS LINE IS PROBLEM #1
	//...

			for(int k = i+1; k <= sizeof(temp) - (i+1); k++)  // THIS LINE
	//...
sizeof() returns type size_t, which a typedef of 'unsigned int'. Also, I think you want temp.size() for your comparison. The above is essensially the same as: sizeof( std::string );
Cache is offline   Reply With Quote
Old May 22nd, 2006, 5:52 PM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
int scriptSize = sizeof(script)/sizeof(script[0]);
This will not work. A std::string is not just a collection of characters. It's a linked list of characters with other variables and functions thrown into the mix.

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;
}
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 22nd, 2006, 6:38 PM   #6
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 266
Rep Power: 4 Cache is on a distinguished road
Quote:
Originally Posted by Ooble
int scriptSize = sizeof(script)/sizeof(script[0]);
This will not work. A std::string is not just a collection of characters. It's a linked list of characters with other variables and functions thrown into the mix.
That depends on what you think it's going to do. Note that 'script' is an array of std::string. Each element of the array will == sizeof( std::string ). So, if you use 'sizeof(script)/sizeof(script[0])' to calculate the number of elements in the array, it will work.
Cache is offline   Reply With Quote
Old May 22nd, 2006, 6:43 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Ah, crap... ignore me. Must be late.

OK, if you want some useful advice, how 'bout this: use a freakin' std::vector instead?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 22nd, 2006, 6:51 PM   #8
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by Ooble
A std::string is not just a collection of characters. It's a linked list of characters with other variables and functions thrown into the mix.
Ooble you should know better than to provide misinformation. std::string is not a linked list of characters.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old May 22nd, 2006, 6:54 PM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 22nd, 2006, 6:55 PM   #10
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3 Jimbo is on a distinguished road
nnxion:
Quote:
Originally Posted by Ooble
Ah, crap... ignore me. Must be late.
:p

[edit:] since std::string supports arbitrary indexing, I doubt a linked list would be used...
Jimbo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:18 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC