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

Defining property getters and settings in cpp file

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,
Nov 20 '06 #1
4 1930
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;
}
Nov 20 '06 #2

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

Nov 20 '06 #3
Hi adebaene!
>VolumeInfo.cpp

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

void VolumeInfo::VolumeDataList::set(List<VolumeData ^>^
volumeDataList)
{
//...
}
Upps...
Thanx for the info!

Greetings
Jochen
Nov 20 '06 #4
ad******@club-internet.fr wrote:
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
Thank you :)
Nov 20 '06 #5

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

Similar topics

11
by: Laszlo Zsolt Nagy | last post by:
My problem is about properties and the virtuality of the methods. I would like to create a property whose get and set methods are virtual. I had the same problems in Delphi before and the solution...
3
by: Tom | last post by:
I am having trouble serializing a color property. Basically, it is not serializing the value. For instance, in the following: <Serializable()> _ Public Class TestColor Private _MyColor As...
7
by: none | last post by:
I'm trying to implement a simple repeateable property mechansism so I don't have to write accessors for every single instance variable I have. ------------ classMyObject: def __init__ (self):...
27
by: sklett | last post by:
I just found myself doing something I haven't before: <code> public uint Duration { get { uint duration = 0; foreach(Thing t in m_things) { duration += t.Duration;
7
by: Jaimi McEntire | last post by:
Given a property define like this: public decimal ControlAmount { get { return mControlAmount; } set { mControlAmount = value; } } I expected (under release mode) that when used as a...
4
by: Brian McCullough | last post by:
Hello, I have a single Web Site Project (WSP, not Web Application Project/WAP). I don't have a WDP project with this, so I don't have a need for a solution file (.sln). I have noticed that my...
5
by: chapeau_melon | last post by:
Hello, I'm basicly not a programmer... I found some C++ codes on the net that almost satisfy me needs, wich is to communicate with an other device that sends data to me, wich I have to receive...
2
by: =?Utf-8?B?Z2FkeWE=?= | last post by:
I use one of 2 arrays dependent on the country. Rather than say: if exchangeID = 1 then dim myPlaceBets() as As UK.exchange.PlaceBets many statements myPlaceBetsReq.bets = myPlaceBets else...
8
by: Hussein B | last post by:
Hey, I noted that Python encourage the usage of: -- obj.prop = data x = obj.prop -- to set/get an object's property value. What if I want to run some logic upon setting/getting a property?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.