473,320 Members | 1,883 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,320 software developers and data experts.

What(s wrong with that :


class Folder
{
public:
friend class PimItemCollection;

Folder(OutlookSession* pOutlookSession);

virtual PimItemCollection* get_Items();

protected:
bool GetPOOMFolder();
OutlookSession* m_pOutlookSession;
OlDefaultFolders m_eFolderType;
IFolderPtr m_pIFolder;
PimItemCollection* m_pContactCol;
};

class ContactFolder : public Folder
{
public:

// Constructor/destructor
ContactFolder(OutlookSession* pOutlookSession);
~ContactFolder();

virtual ContactCollection* get_Items();

private:

};
I have ContactFolder deriving from Folder.
But when I compile I got the following error :

System.WindowsMobile.PocketOutlook.cpp(107) : error C2614:
'System::WindowsMobile::PocketOutlook::ContactFold er' : illegal member
initialization: 'm_eFolderType' is not a base or member
ContactFolder::ContactFolder(OutlookSession* pOutlookSession)
: Folder(pOutlookSession),
m_eFolderType( olFolderContacts )
{

}

Aug 27 '06 #1
4 1481
Vincent RICHOMME wrote:
>
class Folder
{
public:
friend class PimItemCollection;

Folder(OutlookSession* pOutlookSession);

virtual PimItemCollection* get_Items();

protected:
bool GetPOOMFolder();
OutlookSession* m_pOutlookSession;
OlDefaultFolders m_eFolderType;
IFolderPtr m_pIFolder;
PimItemCollection* m_pContactCol;
};

class ContactFolder : public Folder
{
public:

// Constructor/destructor
ContactFolder(OutlookSession* pOutlookSession);
~ContactFolder();

virtual ContactCollection* get_Items();

private:

};
I have ContactFolder deriving from Folder.
But when I compile I got the following error :

System.WindowsMobile.PocketOutlook.cpp(107) : error C2614:
'System::WindowsMobile::PocketOutlook::ContactFold er' : illegal member
initialization: 'm_eFolderType' is not a base or member
ContactFolder::ContactFolder(OutlookSession* pOutlookSession)
: Folder(pOutlookSession),
m_eFolderType( olFolderContacts )
{

}
Well, the compiler is correct. m_eFolderType is a member of Folder, and so
it can only be initialized in the initializer list of Folder's constructor.

Aug 27 '06 #2
Rolf Magnus a écrit :
Vincent RICHOMME wrote:
>class Folder
{
public:
friend class PimItemCollection;

Folder(OutlookSession* pOutlookSession);

virtual PimItemCollection* get_Items();

protected:
bool GetPOOMFolder();
OutlookSession* m_pOutlookSession;
OlDefaultFolders m_eFolderType;
IFolderPtr m_pIFolder;
PimItemCollection* m_pContactCol;
};

class ContactFolder : public Folder
{
public:

// Constructor/destructor
ContactFolder(OutlookSession* pOutlookSession);
~ContactFolder();

virtual ContactCollection* get_Items();

private:

};
I have ContactFolder deriving from Folder.
But when I compile I got the following error :

System.WindowsMobile.PocketOutlook.cpp(107) : error C2614:
'System::WindowsMobile::PocketOutlook::ContactFol der' : illegal member
initialization: 'm_eFolderType' is not a base or member
ContactFolder::ContactFolder(OutlookSession* pOutlookSession)
: Folder(pOutlookSession),
m_eFolderType( olFolderContacts )
{

}

Well, the compiler is correct. m_eFolderType is a member of Folder, and so
it can only be initialized in the initializer list of Folder's constructor.
So if I need to change it, do I need to do it inside the constructor ?

Aug 27 '06 #3
Vincent RICHOMME wrote:
Rolf Magnus a écrit :
Vincent RICHOMME wrote:
class Folder
{
public:
friend class PimItemCollection;

Folder(OutlookSession* pOutlookSession);

virtual PimItemCollection* get_Items();

protected:
bool GetPOOMFolder();
OutlookSession* m_pOutlookSession;
OlDefaultFolders m_eFolderType;
IFolderPtr m_pIFolder;
PimItemCollection* m_pContactCol;
};

class ContactFolder : public Folder
{
public:

// Constructor/destructor
ContactFolder(OutlookSession* pOutlookSession);
~ContactFolder();

virtual ContactCollection* get_Items();

private:

};
I have ContactFolder deriving from Folder.
But when I compile I got the following error :

System.WindowsMobile.PocketOutlook.cpp(107) : error C2614:
'System::WindowsMobile::PocketOutlook::ContactFold er' : illegal member
initialization: 'm_eFolderType' is not a base or member
ContactFolder::ContactFolder(OutlookSession* pOutlookSession)
: Folder(pOutlookSession),
m_eFolderType( olFolderContacts )
{

}
Well, the compiler is correct. m_eFolderType is a member of Folder, andso
it can only be initialized in the initializer list of Folder's constructor.

So if I need to change it, do I need to do it inside the constructor ?
No, at least not in the body of the constuctor. Your Folder class
needs to provide a constructor that initializes all of its members that
require initialization (including m_eFolderType), and then
ContactFolder must provide a constructor that calls the Folder
constructor in its initialization list. Let's take a simple example:

class Parent {
int i;
public:
Parent(int j) : i(j) {}
};

class Child : public Parent {
public:
// the following line is an ERROR:
// Child (int k) : i(k) {}
// the following line is the correct way to initialize Parent::i
Child(int k) : Parent(k) {}
};

Hope that helps.

Best regards,

Tom

Aug 27 '06 #4
Thomas Tutone wrote:

[snip]
So if I need to change it, do I need to do it inside the constructor ?

No, at least not in the body of the constuctor. Your Folder class
needs to provide a constructor that initializes all of its members that
require initialization (including m_eFolderType), and then
ContactFolder must provide a constructor that calls the Folder
constructor in its initialization list. Let's take a simple example:
class Parent {
Although this example is correct, to make it more similar to your class
definition, add the following line here:

protected:
int i;
public:
Parent(int j) : i(j) {}
};

class Child : public Parent {
public:
// the following line is an ERROR:
// Child (int k) : i(k) {}
// the following line is the correct way to initialize Parent::i
Child(int k) : Parent(k) {}
};
Also, note that many people would advise you to use private, rather
than protected, data members in your parent class. The FAQ discusses
the issue (although takes a more permissive stance on the subject):

http://www.parashift.com/c++-faq-lit....html#faq-19.8

But in any case, you can see that making the member protected does not
offer any advantage with respect to initialization lists.

Best regards,

Tom

Aug 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
4
by: Fang | last post by:
Hi, I'm new to PHP. I followed an example on the book and wanted to pass a variable from one html page to a php page, but it always tells me the passed variable is undefined. I've checked the...
1
by: Thorsan | last post by:
im doing the following: int _tmain(int argc, _TCHAR* argv) { typedef double matrix4x4; matrix4x4 *mat = (matrix4x4*)malloc(sizeof(matrix4x4));
3
by: John Smith | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <div id="navcontainer"> <ul...
5
by: Koen | last post by:
Hi all, I am experimenting with DAO. I wrote this sub to update one specific field of one specific row in one specific table. Nothing wrong with the SQL statement, but when I execute this I get...
8
by: Polaris | last post by:
Hi Experts: The program creates Panels and inicilize them. When I run the code below, the program crashes (at the line commented below). Any help is appriciated. Thanks in Advance! Polaris ...
2
by: MikeY | last post by:
Hi Everyone, I'm having problems with my syntax on the updating part for the Northwind.MDB. All other code seems fine. It has to do with the Order Details on the thisAdapter.Update( ). Or I...
14
by: howa | last post by:
void reverse_string(char *str) { if (str == NULL) return; char tmp; size_t len = strlen(str); size_t mid = (int) len / 2; for (size_t i = 0; i < mid; i++) {
5
by: ASP.NET explorer | last post by:
http://news.netcraft.com/ has a simple utility "What that site is running?" that lets us know the server software of a website. http://toolbar.netcraft.com/site_report?url=http://www.sap.com I...
3
by: lenygold via DBMonster.com | last post by:
CREATE FUNCTION dates(start DATE, end DATE) RETURNS TABLE(dt DATE) RETURN WITH REC (DT) AS (VALUES(DATE(START)) UNION ALL SELECT DT + 1 DAY FROM REC WHERE DT < END) SELECT DT FROM REC;
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.