Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2006

Tip: Looking for answers? Try searching our database.

Defining property getters and settings in cpp file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Ingram - 20 Nov 2006 11:01 GMT
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,
Jochen Kalmbach [MVP] - 20 Nov 2006 13:03 GMT
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;
}
adebaene@club-internet.fr - 20 Nov 2006 13:23 GMT
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?
[quoted text clipped - 12 lines]
>
> VolumeInfo.cpp

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

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

Arnaud
MVP - VC
Jochen Kalmbach [MVP] - 20 Nov 2006 13:51 GMT
Hi adebaene!

>> VolumeInfo.cpp
>
[quoted text clipped - 8 lines]
>   //...
> }

Upps...
Thanx for the info!

Greetings
  Jochen
Mark Ingram - 20 Nov 2006 14:02 GMT
> Mark Ingram a écrit :
>
[quoted text clipped - 28 lines]
> Arnaud
> MVP - VC

Thank you :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.