Sponsored Content
Top Forums Programming why constructor cannot be virtual Post 302130103 by porter on Friday 3rd of August 2007 03:02:17 AM
Old 08-03-2007
Quote:
Originally Posted by amitpansuria
can u explain me in simple term that why constructor cannot be virtual
Virtual works by the object pointing to a v-table, and the caller dereferencing the call via the v-table. Immediately prior to construction time you don't have an object which points to a vtable to make the call.

Solutions to this include using factory objects, which is exactly what COM does with IClassFactory so the call to CreateInstance is virtual. Similarly IBM's SOMClass::somNew.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Constructor problem

Hi guys I am new to these forums but since I am taking a class at college I would appreciate any help that is possible for this program. My instructor said that when its complete the program should be able to store all 3 fields instead of just 1. public class Greeter2Test { public static... (4 Replies)
Discussion started by: woot4moo
4 Replies

2. Programming

how do you handle a constructor and destructor that fail

helo i m new in c++ on linux can u tell me with an simple example that how do you handle constructor and destructor that fail? Regards, Amit (4 Replies)
Discussion started by: amitpansuria
4 Replies

3. Programming

Doubt regarding Copy Constructor and return value

Hi All, I have made the simple following program :- #include <string> #include <iostream> using namespace std; class A{ private: int val; public : A(){cout<<"In A()"<<endl;} A (const A& aa) { cout<<"In copy c'tor"<<endl; } }; A f(... (1 Reply)
Discussion started by: shubhranshu
1 Replies

4. UNIX for Dummies Questions & Answers

Have to log out of a virtual terminal twice in order to exit virtual terminals

Not really a newbie, but I have a strange problem and I'm not sure how to further troubleshoot it. I have to log out of a virtual terminal by typing exit, then exit again as in: woodnt@toshiba-laptop ~ $ exit logout woodnt@toshiba-laptop ~ $ exit logout I DON'T have to do this when I'm... (1 Reply)
Discussion started by: Narnie
1 Replies

5. Programming

c++ object constructor question

I have the following code class Param{ public: Param(int aa, int bb){ a=aa; b=bb; } int a,b; }; void function(Param); int main(){ function(2,3); return 0; } (6 Replies)
Discussion started by: santiagorf
6 Replies

6. Programming

Doubts on C++ copy constructor concept

Hi, If I run the following program class A { public: A() { cout << "default" << endl; } A(const A&) { cout << "copy" << endl; } }; A tmp; A fun() { return tmp; } A test() { A tmp; cout << &tmp << endl; return tmp; } (1 Reply)
Discussion started by: royalibrahim
1 Replies

7. Solaris

Change hostID of Solaris 10 virtual/guest machine installed by Virtual Box 4.1.12 on Windows-XP host

Trying to set or modify the randomly set hostID of a Solaris 10 virtual/guest machine that I installed on a Windows-XP host machine (using Virtual Box 4.1.12). I was able to set/modify the hostname of the Solaris 10 virtual/guest machine during installation as well as via the Virtual Box... (4 Replies)
Discussion started by: Matt_VB
4 Replies

8. Programming

Constructor?

I am learning about C++ and today am reading concepts for Constructor but it seems a bit difficult to grab it fully. Please anyone explain in simple words about Constructor? (1 Reply)
Discussion started by: ggiwebsinfo
1 Replies

9. UNIX for Beginners Questions & Answers

Providing virtual machine priority in kvm based virtual machines

Hi All, Is there any way I can prioritize my VMs when there is resource crunch in host machine so that some VMs will be allocated more vcpu, more memory than other VMs in kvm/qemu hypervisor based virtual machines? Lets say in my cloud environment my Ubuntu 16 compute hosts are running some... (0 Replies)
Discussion started by: SanjayK
0 Replies
QImageFormatType(3qt)													     QImageFormatType(3qt)

NAME
QImageFormatType - Factory that makes QImageFormat objects SYNOPSIS
#include <qasyncimageio.h> Public Members virtual ~QImageFormatType () virtual QImageFormat * decoderFor ( const uchar * buffer, int length ) = 0 virtual const char * formatName () const = 0 Protected Members QImageFormatType () DESCRIPTION
The QImageFormatType class is a factory that makes QImageFormat objects. Whereas the QImageIO class allows for complete loading of images, QImageFormatType allows for incremental loading of images. New image file formats are installed by creating objects of derived classes of QImageFormatType. They must implement decoderFor() and formatName(). QImageFormatType is a very simple class. Its only task is to recognize image data in some format and make a new object, subclassed from QImageFormat, which can decode that format. The factories for formats built into Qt are automatically defined before any other factory is initialized. If two factories would recognize an image format, the factory created last will override the earlier one; you can thus override current and future built-in formats. See also Graphics Classes, Image Processing Classes, and Multimedia Classes. MEMBER FUNCTION DOCUMENTATION
QImageFormatType::QImageFormatType () [protected] Constructs a factory. It automatically registers itself with QImageDecoder. QImageFormatType::~QImageFormatType () [virtual] Destroys a factory. It automatically unregisters itself from QImageDecoder. QImageFormat * QImageFormatType::decoderFor ( const uchar * buffer, int length ) [pure virtual] Returns a decoder for decoding an image that starts with the bytes in buffer. The length of the data is given in length. This function should only return a decoder if it is certain that the decoder applies to data with the given header. Returns 0 if there is insufficient data in the header to make a positive identification or if the data is not recognized. const char * QImageFormatType::formatName () const [pure virtual] Returns the name of the format supported by decoders from this factory. The string is statically allocated. SEE ALSO
http://doc.trolltech.com/qimageformattype.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qimageformattype.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QImageFormatType(3qt)
All times are GMT -4. The time now is 06:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy