473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing values to a class

Hello

I have a program as given in following,

class CCmdValue
{
int a, b;
void Put(int x, int y) { a = x; c = y;}
};

class CCmdData
{
CCmdValue pValue;
pValue->Put(10, 20);

CCmdModule pCmd;
pCmd.NewValues(pValue);
};

class CCmdModule
{
friend class CCmdModuleFactory;
CCmdValue mValue;
};

class CCmdModuleFactory
{
CCmdModule& NewValues(CCmdValue& pValue)
{
CCmdModule* p = new CCmdModule;
p->mValue = pValue; // THIS LINE FAILS
}
};

When i try to pass the value of "pValue" to "mValue" It fails. It
doesn't give any compilation error, but when i try to read the integer
values, they don't have any vlaues assigned to them.

Any idea why thats happening?

Thanks in advance.

Oct 9 '07 #1
2 1337
Donos wrote:
Hello

I have a program as given in following,

class CCmdValue
{
int a, b;
void Put(int x, int y) { a = x; c = y;}
};
This class has no public methods, so you can't really do anything with
it other than default construct, copy construct, or assign it.
>
class CCmdData
{
CCmdValue pValue;
pValue->Put(10, 20);
This should give a compile-time error.
CCmdModule pCmd;
pCmd.NewValues(pValue);
};

class CCmdModule
{
friend class CCmdModuleFactory;
CCmdValue mValue;
};

class CCmdModuleFactory
{
CCmdModule& NewValues(CCmdValue& pValue)
{
CCmdModule* p = new CCmdModule;
p->mValue = pValue; // THIS LINE FAILS
}
};

When i try to pass the value of "pValue" to "mValue" It fails. It
doesn't give any compilation error, but when i try to read the integer
values, they don't have any vlaues assigned to them.

Any idea why thats happening?
How about providing a minimal, compilable, executable sample that
exhibits the behavior in question?

Oct 9 '07 #2
"Donos" <do******@gmail.comwrote in message
news:11*********************@22g2000hsm.googlegrou ps.com...
Hello

I have a program as given in following,

class CCmdValue
{
int a, b;
void Put(int x, int y) { a = x; c = y;}
};

class CCmdData
{
CCmdValue pValue;
pValue->Put(10, 20);

CCmdModule pCmd;
pCmd.NewValues(pValue);
};

class CCmdModule
{
friend class CCmdModuleFactory;
CCmdValue mValue;
};

class CCmdModuleFactory
{
CCmdModule& NewValues(CCmdValue& pValue)
{
CCmdModule* p = new CCmdModule;
p->mValue = pValue; // THIS LINE FAILS
}
};

When i try to pass the value of "pValue" to "mValue" It fails. It
doesn't give any compilation error, but when i try to read the integer
values, they don't have any vlaues assigned to them.

Any idea why thats happening?
Doing almost anything with these classes as they are shown here will give
compile time errors, since nothing is declared public. Everything is
private to each of the classes. Also, there are syntax errors. CCmdValue
pValue; is an instance. Yet you use it as a pointer, which would produce an
error.

Please show the actual code that is causing the problem.
Oct 10 '07 #3

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

Similar topics

3
16811
by: Andy Read | last post by:
Dear all, I thought I understood passing parameters ByVal and ByRef but I clearly don't! If I define a simple class of: Public Class Person Public Name as String Public Age as Integer End...
11
3159
by: Arsen Vladimirskiy | last post by:
Hello, If I have a few simple classes to represent Entities such as Customers and Orders. What is the proper way to pass information to the Data Access Layer? 1) Pass the actual ENTITY to...
4
4860
by: Ron Rohrssen | last post by:
I want to show a dialog and when the form (dialog) is closed, return to the calling form. The calling form should then be able to pass the child form to another object with the form as a...
4
3130
by: rick | last post by:
Does anyone having a working example of passing values between web forms pages? I tried the example in the ms- help but I can't get by the following: To read property values from the source...
7
4732
by: Ken Allen | last post by:
I have a .net client/server application using remoting, and I cannot get the custom exception class to pass from the server to the client. The custom exception is derived from ApplicationException...
0
1057
by: Greg Merideth | last post by:
I ran into a small snag in passing in a class as a parameter to a web method from our calling code. Now, we routinely pass *back* as a return value from a method, a class reference and that...
10
3453
by: Stan | last post by:
There are two ways to pass structured data to a web service: xml === <Order OrderId="123" OrderAmount="234" /> or class =====
3
2087
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
5
1880
by: Markus Ernst | last post by:
Hello A class that composes the output of shop-related data gets some info from the main shop class. Now I wonder whether it is faster to store the info in the output class or get it from the...
7
3290
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
0
7083
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
7278
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,...
1
6988
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
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
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,...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3166
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.