Click here to Skip to main content
15,915,081 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalvector problem Pin
BlackDice1-Jun-04 5:19
BlackDice1-Jun-04 5:19 
GeneralRe: vector problem Pin
Diddy1-Jun-04 5:34
Diddy1-Jun-04 5:34 
GeneralRe: vector problem Pin
BlackDice1-Jun-04 5:42
BlackDice1-Jun-04 5:42 
GeneralM.S.Chart Problem Pin
Member 3287141-Jun-04 4:59
Member 3287141-Jun-04 4:59 
GeneralMemory device context help Pin
JHAKAS1-Jun-04 4:55
JHAKAS1-Jun-04 4:55 
GeneralRe: Memory device context help Pin
JHAKAS1-Jun-04 5:11
JHAKAS1-Jun-04 5:11 
GeneralRe: Memory device context help Pin
PJ Arends1-Jun-04 22:05
professionalPJ Arends1-Jun-04 22:05 
GeneralIllegal conversion warning Pin
Jim Crafton1-Jun-04 4:15
Jim Crafton1-Jun-04 4:15 
The following code, which compiles just fine on VC6, apparently causes the VC7.1 (and presumably VC7.0) compiler to wet it's pants. I don't understand why?

#include <string>



class String {
public:
	~String() { /**/ };

	String(){};

	String(const String& rhs) {
		*this = rhs;
	}

	String(const std::string& rhs) {
		//
	};
};

class Path {
	public:
		Path() { /**/ };

		Path( const String& filename ); // implementation not even used

		Path( const Path& filePath );		// implementation not even used

		virtual ~Path() { /**/ };

		inline Path& operator= ( const Path& path ){
			filename_ = path.filename_;
			return *this;
		}


		inline Path& operator= ( const String& filename ) {
			filename_ = filename;
			return *this;
		}

		inline operator String () const {
			return filename_;
		}

		inline operator String& () {
			return filename_;
		}

public:
		String filename_;
};


class ConversionClass {
public:
	ConversionClass() {
	}

	String getFileName() {
		return filePath_;
	}

	Path filePath_;
};




int main(int argc, char *argv[])
{
	ConversionClass* conversionClass = new ConversionClass();
	String s = conversionClass->getFileName();

	return 0;
}

The actuall warning/error is:

d:\code\junk\cvt\Conversion_c.cpp(68) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied
        while calling the constructor 'String::String(const String &)'
        d:\code\junk\cvt\Conversion_c.cpp(13) : see declaration of 'String::String'


Any thoughts, suggestions on how to get rid of this would be most welcome, and I'll be sure to have Bob send you a cookie Smile | :)



¡El diablo está en mis pantalones! ¡Mire, mire!

Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!

SELECT * FROM User WHERE Clue > 0
0 rows returned

GeneralRe: Illegal conversion warning Pin
Antony M Kancidrowski1-Jun-04 4:39
Antony M Kancidrowski1-Jun-04 4:39 
GeneralRe: Illegal conversion warning Pin
Antony M Kancidrowski1-Jun-04 4:48
Antony M Kancidrowski1-Jun-04 4:48 
GeneralRe: Illegal conversion warning Pin
Michael Dunn1-Jun-04 5:04
sitebuilderMichael Dunn1-Jun-04 5:04 
GeneralRe: Illegal conversion warning Pin
Marcello1-Jun-04 6:16
Marcello1-Jun-04 6:16 
GeneralRe: Illegal conversion warning Pin
Marcello1-Jun-04 6:41
Marcello1-Jun-04 6:41 
GeneralRe: Illegal conversion warning Pin
Anonymous17-Jun-04 9:53
Anonymous17-Jun-04 9:53 
GeneralUsing TRACE macro Pin
Anonymous1-Jun-04 3:24
Anonymous1-Jun-04 3:24 
GeneralRe: Using TRACE macro Pin
David Crow1-Jun-04 3:41
David Crow1-Jun-04 3:41 
GeneralRe: Using TRACE macro Pin
jmkhael1-Jun-04 3:45
jmkhael1-Jun-04 3:45 
GeneralRe: Using TRACE macro Pin
Anonymous1-Jun-04 8:43
Anonymous1-Jun-04 8:43 
GeneralRe: Using TRACE macro Pin
Anonymous1-Jun-04 9:01
Anonymous1-Jun-04 9:01 
GeneralMy Dialog-Window (not minimized), is hidden under other windows, how to make active/top/etc Pin
ohadp1-Jun-04 3:24
ohadp1-Jun-04 3:24 
GeneralRe: My Dialog-Window (not minimized), is hidden under other windows, how to make active/top/etc Pin
Antony M Kancidrowski1-Jun-04 4:11
Antony M Kancidrowski1-Jun-04 4:11 
GeneralRe: My Dialog-Window (not minimized), is hidden under other windows, how to make active/top/etc Pin
ohadp1-Jun-04 4:27
ohadp1-Jun-04 4:27 
GeneralRe: My Dialog-Window (not minimized), is hidden under other windows, how to make active/top/etc Pin
Antony M Kancidrowski1-Jun-04 4:52
Antony M Kancidrowski1-Jun-04 4:52 
GeneralRe: My Dialog-Window (not minimized), is hidden under other windows, how to make active/top/etc Pin
ohadp1-Jun-04 4:57
ohadp1-Jun-04 4:57 
GeneralRe: My Dialog-Window (not minimized), is hidden under other windows, how to make active/top/etc Pin
Antony M Kancidrowski1-Jun-04 23:39
Antony M Kancidrowski1-Jun-04 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.