GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Dec-2004, 16:48
crystalattice's Avatar
crystalattice crystalattice is offline
Flame War Instigator
 
Join Date: Apr 2004
Location: San Diego
Posts: 1,534
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

"No matching function" error


When trying to compile my program, I get:
Code:
/home/cody/Projects/wavelength/src/wavelength.cpp:20: no matching function for call to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::wavelength()'
It's referring to the cout line of my main program, but I don't understand exactly what it's trying to tell me. AFAIK, the cout line should be calling for the wavelength() function for a specific color, which the user entered.

Any ideas? Thanks. (As the files are somewhat long, I thought it best to just attach them.)
Attached Files
File Type: zip src.zip (2.8 KB, 7 views)
__________________
Common Sense v2.0-Striving to make the world a little bit smarter.
  #2  
Old 03-Dec-2004, 04:03
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 889
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough
I really don't get your code.
You have:

CPP / C++ / C Code:
	string theColor;
	cin >> theColor;

	cout << "\nThe corresponding wavelength is " << theColor.wavelength() << endl;

But wavelength is a method in class Color, not in std::string; that's what the compiler is complaining about.

I kind of got the idea of what you are trying to accomplish, but come on!

Best regards,
Luci
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #3  
Old 03-Dec-2004, 04:32
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 889
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough
I see you have a conversion constructor for Color, but it is an abstract class and can't instantiate it!
Plus I think you need something like this to "invoke" the constructor:

CPP / C++ / C Code:
Color color = theColor;

I'm sure you head something (really complicated ) in mind when you wrote this, but (at least) I need some further explanations to follow you. I guess I'm kind of tired - can't wait for the weekend

Kind regards,
Luci

[edit]
Where are these things defined? (things = RED, ORANGE...)
CPP / C++ / C Code:
	if (colorString == "RED")                          // map to ColorValue
		myName = RED;
	else if (colorString == "ORANGE")
		myName = ORANGE;
	else if (colorString == "YELLOW")
		myName = YELLOW;
	else if (colorString == "GREEN")
		myName = GREEN;
	else if (colorString == "BLUE")
		myName = BLUE;
	else if (colorString == "INDIGO")
		myName = INDIGO;
	else if (colorString == "VIOLET")
		myName = VIOLET;
[/edit]
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #4  
Old 03-Dec-2004, 09:57
crystalattice's Avatar
crystalattice crystalattice is offline
Flame War Instigator
 
Join Date: Apr 2004
Location: San Diego
Posts: 1,534
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice
Honestly, I'm just tired of fighting w/ this problem. I've been working on it for nearly a month, using the help from this forum, my school's forum, and waiting in vain for help from my teacher. I did get a small code file from him, which included the else/if statements you noted, but no guidance on how to fix my problems.

I didn't even notice the fact I was calling a Color class method with the input string name. I think I see something of what I need to do, based on your questions. I'll play w/ it a little more.

Thanks for the kick in the butt. :-P
__________________
Common Sense v2.0-Striving to make the world a little bit smarter.
 
 

Recent GIDBlogA Week in Kuwait by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
Operator Overloading: << aaroncohn C++ Forum 36 07-Dec-2004 19:22
link error? pablowablo C++ Forum 14 19-Jun-2004 10:00
OpenGL always reports error mvt OpenGL Programming 2 04-Jun-2004 06:42
Visual C++ 6 Compiler error vip3r C++ Forum 2 13-Apr-2004 14:34

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:18.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.