• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C++ constructors.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ constructors.


  • Subject: Re: C++ constructors.
  • From: Alastair Houghton <email@hidden>
  • Date: Wed, 13 May 2009 18:14:52 +0100

On 13 May 2009, at 15:16, Тимофей Даньшин wrote:

Hi there.

Here is a C++ constructor that is said to work on Windows (i.e., the guy who wrote it says it works on Win), but doesn't work on Mac. Is there a way to fix it, except by replacing it with a "copy" method?

Cbyte1::Cbyte1 (Cbyte1 &val) {
	m_size = val.m_size;
	if (m_size == 0) {
		m_totalmax = 0;
		b = "";
		return;
	}
}

Hi Timofey,

This isn't really a Cocoa question, so this isn't really the right list to be asking.

That said, the rules about which constructor (or for that matter function) gets chosen are very complicated. It may be that there are implicit conversions going on that mean that the compiler can't decide which of the constructors to use (for instance, if there happened to be a conversion method from Cbyte1 to an "int", you might have the problem you're seeing).

The solution is most likely to add the keyword "explicit" to some of the constructors, or to remove the conversion method (assuming it exists).

Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >C++ constructors. (From: Тимофей Даньшин <email@hidden>)

  • Prev by Date: Re: [iPhone] Caching images fetched from a URL?
  • Next by Date: Re: Win->MacOS porting question.
  • Previous by thread: Re: C++ constructors.
  • Next by thread: Displaying Application name
  • Index(es):
    • Date
    • Thread