Defining property getters and settings in cpp file

M

Mark Ingram

Hi, does anyone know if it is possible to define the function body of a
getter and setter in the .cpp file?

I have tried this, but it doesn't work (Error 1 error C2039:
'get_VolumeDataList' : is not a member of 'VolumeInfo'
d:\\VolumeInfo.cpp 7)



VolumeInfo.h

property List<VolumeData ^>^ VolumeDataList
{
List<VolumeData ^>^ get();
void set(List<VolumeData ^>^ volumeDataList);
}


VolumeInfo.cpp

List<VolumeData ^>^ VolumeInfo::get_VolumeDataList()
{
return m_volumeDataList;
}

void VolumeInfo::set_VolumeDataList(List<VolumeData ^>^ volumeDataList)
{
m_volumeDataList = volumeDataList;
}

The reason I want to put it in the .cpp file is because I have some
extra error checking that I want to add in, without padding out the
class definition (.h file).

Thanks,
 
J

Jochen Kalmbach [MVP]

Hi Mark!
Hi, does anyone know if it is possible to define the function body of a
getter and setter in the .cpp file?


It seems that you need to use a "helper-method" which must be called in
the h-File...
Something like:

property List<VolumeData ^>^ VolumeDataList
{
List<VolumeData ^>^ get() { return Get_VolumeDataList(); }
void set(List<VolumeData ^>^ volumeDataList); {
Set_VolumeDataList(volumeDataList; }
}



VolumeInfo.cpp

List<VolumeData ^>^ VolumeInfo::Get_VolumeDataList()
{
return m_volumeDataList;
}

void VolumeInfo::Set_VolumeDataList(List<VolumeData ^>^ volumeDataList)
{
m_volumeDataList = volumeDataList;
}
 
A

adebaene

Mark Ingram a écrit :
Hi, does anyone know if it is possible to define the function body of a
getter and setter in the .cpp file?

I have tried this, but it doesn't work (Error 1 error C2039:
'get_VolumeDataList' : is not a member of 'VolumeInfo'
d:\\VolumeInfo.cpp 7)



VolumeInfo.h

property List<VolumeData ^>^ VolumeDataList
{
List<VolumeData ^>^ get();
void set(List<VolumeData ^>^ volumeDataList);
}


VolumeInfo.cpp

List<VolumeData ^>^ VolumeInfo::VolumeDataList::get()
{
//....
}

void VolumeInfo::VolumeDataList::set(List<VolumeData ^>^
volumeDataList)
{
//...
}

Arnaud
MVP - VC
 
J

Jochen Kalmbach [MVP]

Hi adebaene!
List<VolumeData ^>^ VolumeInfo::VolumeDataList::get()
{
//....
}

void VolumeInfo::VolumeDataList::set(List<VolumeData ^>^
volumeDataList)
{
//...
}

Upps...
Thanx for the info!

Greetings
Jochen
 
M

Mark Ingram

Mark Ingram a écrit :




List<VolumeData ^>^ VolumeInfo::VolumeDataList::get()
{
//....
}

void VolumeInfo::VolumeDataList::set(List<VolumeData ^>^
volumeDataList)
{
//...
}

Arnaud
MVP - VC

Thank you :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top