473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Initializing constructor in CPropertyPage

3
Here is a declaration of property class
class CMyPropertyPage11 : public CPropertyPage

Here is the definition
CMyPropertyPage11::CMyPropertyPage11() : CPropertyPage(CMyPropertyPage11::IDD)

I really do not understand the role of the
CPropertyPage(CMyPropertyPage11::IDD)

But I need to derive CMyPropertyPage11 from another CPropertyPage, say CBasePropertyPage adn really need to know how to implement the CPropertyPage(CMyPropertyPage11::IDD) initialization again.
Aug 21 '13 #1
3 1652
weaknessforcats
9,208 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. class CMyPropertyPage11 : public CPropertyPage 
This says class CMyPropertyPage11 is a derived class of CPropertyPage

Expand|Select|Wrap|Line Numbers
  1.   CMyPropertyPage11::CMyPropertyPage11() : CPropertyPage(CMyPropertyPage11::IDD)
  2.  
This says the default constructor of CMyPropertyPage11() calls the base class constructor of CPropertyPage using CMyPropertyPage11::IDD as an argument.

The initializer list (:) of CMyPropertyPage11() guarantees that CPropertyPage::CPropertyPage(CMyPropertyPage11::ID D) is called before the CMyPropertyPage11() constructor executes.

It is important that all base class data members are initialized before attempting to initialize derived class members in the event the derived class requires information from the base class in order to proceed.

Were this not done, when you create a CMyPropertyPage11 object, the CPropertyPage::CPropertyPage() constructor would be called instead. The base portion of your CMyPropertyPage11 object would now be missing the CMyPropertyPage11::IDD.
Aug 21 '13 #2
Vaclav
3
Thank you, I think I got it. At least the basics.
Now I am still stuck with the next step.
I need to have all of the the ProperyPagexx have an access to one common instance of a class.
So I build another BaseProperyPage to instantiate such common class.
Now I need to have the original ProperyPageXX inherit from the BaseProperyPage which inherits from ProperyPage.

To do this multiple inheritance the compiler complains that they both inherit from same base and I need to fix than using virtual inheritance. I think I can handle that.
But I am still unclear how am I going to do the original initialization.

Basically I have no clue how to make this “idea” work so it compiles, because my syntax is wrong:
I have deleted all the : so it is little clearer.

CmyPropertyPage11::CMyPropertyPage11 : (?)

CPropertyPage(CMyPropertyPage11::IDD) (?) original initialization

CBasePropertyPage (?) do I really need this

Here is partial, still not working, declaration:

class CMyPropertyPage11 : public CPropertyPage, virtual public CBasePropertyPage


I am getting tons of errors no matter what I try.
Maybe I should just put the original initialization inside the constructor?
I got he whole “property sheet” from VC 6.0 components and obviously need to know some basic before I get to use it for real.
Aug 21 '13 #3
weaknessforcats
9,208 Expert Mod 8TB
You are after a thing called a Singleton. An object for which there is one instance and accessible through a common point.

There is a design pattern called Singleton that does this.

Please read: http://bytes.com/topic/c/insights/65...erns-singleton
Aug 22 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Vamsi | last post by:
Hello, I am working in VC++ environment.while using gdi+, i want to use a public member variable of Bitmap. which needs to be initialized at the time of creation. and i m using this gdi+ in a...
7
by: jimjim | last post by:
Hello all, What other reason is there for using the copy constructor apart from copying data members which are pointers to dynamically allocated objects? TIA
10
by: William Stacey | last post by:
I know the following is not allowed, but shouldn't it be? sharedObject is part of Derived and should be able to be set in the constructor - no? tia public abstract class Base1 { protected...
17
by: Calle Pettersson | last post by:
Coming from writing mostly in Java, I have trouble understanding how to declare a member without initializing it, and do that later... In Java, I would write something like public static void...
2
by: eriwik | last post by:
Given a simple class like class test { private: size_t size_; int* data_; public: test(size_t s) : size_(s), data_(new int { /* ... */ };
1
by: subramanian | last post by:
Consider the following program: #include <iostream> #include <string> class Test { public: Test(const std::string &val); private:
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
53
by: Sanders Kaufman | last post by:
I'm having a BLAST writing this app as OOP as PHP allows. It's one thing to discuss the dance, but it's a thing of beauty to see the performance. I'm noticing that the constructor is a "reset"...
10
by: Jason Doucette | last post by:
Situation: I have a simple struct that, say, holds a color (R, G, and B). I created my own constructors to ease its creation. As a result, I lose the default constructor. I dislike this, but...
2
by: asuna | last post by:
I have a class extends CPropertyPage, I want to add a button in this page, for jumping to another CPropertyPage. But how can I get a pointer of CPropertySheet? Then I can use the SetActivePage()....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.