Hi all,
I'm trying to use forward declaration with value class but I don't succeed
in compiling my (quite simple) sample code.
This is my code I'm trying to compile (Visual Studio 2003)
namespace managedDll
{
public __value class VecDouble;
public __value class VecFloat
{
public:
void SetValue(VecDou ble vec)
{
// TODO
}
};
public __value class VecDouble
{
public:
void SetValue(VecFlo at vec)
{
// TODO
}
};
}
I've got the following error when compiling:
error C2027: use of undefined type 'managedDll::Ve cDouble'
Every think work fine if my SetValues methods have the signature (Vec(Double
| Float) &vec).
The problem is that putting a '&' is not logical because I want to call
methods from C# code and with this signature I should write the following
code
VecDouble vec = new VecDouble();
vecFloat.SetVal ue(ref vec);
Instead I want to call my methods in this way:
vecFloat.SetVal ue(new VecDouble())
The first solution is not acceptable !.
Does anyone encounter the same problem ?
Great thanks.
Jerome 4 1384
Forward declaration by definition only works with pointers (VecDouble* vec) and refenences (VecDouble& vec).
This is because in this cases the parameter is just an address. If you pass an object by value, the compiler
creates a copy of the object on the stack - and therefore needs all the information of the object, e.g. how
many bytes it occupies, whether it has a copy constructor and so on.
Jerome wrote: Hi all,
I'm trying to use forward declaration with value class but I don't succeed in compiling my (quite simple) sample code. This is my code I'm trying to compile (Visual Studio 2003)
namespace managedDll { public __value class VecDouble; public __value class VecFloat { public: void SetValue(VecDou ble vec)
{ // TODO }
};
public __value class VecDouble {
public: void SetValue(VecFlo at vec)
{ // TODO }
}; }
I've got the following error when compiling: error C2027: use of undefined type 'managedDll::Ve cDouble'
Every think work fine if my SetValues methods have the signature (Vec(Double | Float) &vec). The problem is that putting a '&' is not logical because I want to call methods from C# code and with this signature I should write the following code
VecDouble vec = new VecDouble(); vecFloat.SetVal ue(ref vec);
Instead I want to call my methods in this way: vecFloat.SetVal ue(new VecDouble()) The first solution is not acceptable !.
Does anyone encounter the same problem ?
Great thanks. Jerome
I know that ... and that's why I think there's a problem with managed C++
language.
It's not acceptable that a method you think taking a parameter as 'In' must
be signed by 'ref'
Of course the problem does not exists with reference class.
I'm still dreaming of a magic attribute or magic compilation option ... who
knows ? ... certainly Microsoft developpers ... Anyone from Microsoft Visual
Studio team to solve my issue or explain why it can't be possible ???
"Eckart Haug" <Ec*********@lu k.de> a écrit dans le message de
news:db******** **@aftlinux2.we rdohl.aft-werdohl.de... Forward declaration by definition only works with pointers (VecDouble*
vec) and refenences (VecDouble& vec). This is because in this cases the parameter is just an address. If you
pass an object by value, the compiler creates a copy of the object on the stack - and therefore needs all the
information of the object, e.g. how many bytes it occupies, whether it has a copy constructor and so on.
Jerome wrote: Hi all,
I'm trying to use forward declaration with value class but I don't
succeed in compiling my (quite simple) sample code. This is my code I'm trying to compile (Visual Studio 2003)
namespace managedDll { public __value class VecDouble; public __value class VecFloat { public: void SetValue(VecDou ble vec)
{ // TODO }
};
public __value class VecDouble {
public: void SetValue(VecFlo at vec)
{ // TODO }
}; }
I've got the following error when compiling: error C2027: use of undefined type 'managedDll::Ve cDouble'
Every think work fine if my SetValues methods have the signature
(Vec(Double | Float) &vec). The problem is that putting a '&' is not logical because I want to call methods from C# code and with this signature I should write the
following code
VecDouble vec = new VecDouble(); vecFloat.SetVal ue(ref vec);
Instead I want to call my methods in this way: vecFloat.SetVal ue(new VecDouble()) The first solution is not acceptable !.
Does anyone encounter the same problem ?
Great thanks. Jerome
How about something like this:
namespace managedDll
{
public __value class VecDouble;
public __value class VecFloat
{
public:
void SetValue(VecDou ble vec);
};
public __value class VecDouble
{
public:
void SetValue(VecFlo at vec)
{
// TODO
}
};
void VecFloat::SetVa lue(VecDouble vec)
{
// TODO
}
}
"Jerome" <jl****@NOSPAMm c.com> wrote in message
news:Oc******** ******@TK2MSFTN GP10.phx.gbl... I know that ... and that's why I think there's a problem with managed C++ language. It's not acceptable that a method you think taking a parameter as 'In' must be signed by 'ref' Of course the problem does not exists with reference class.
I'm still dreaming of a magic attribute or magic compilation option ... who knows ? ... certainly Microsoft developpers ... Anyone from Microsoft Visual Studio team to solve my issue or explain why it can't be possible ???
"Eckart Haug" <Ec*********@lu k.de> a écrit dans le message de news:db******** **@aftlinux2.we rdohl.aft-werdohl.de... Forward declaration by definition only works with pointers (VecDouble* vec) and refenences (VecDouble& vec). This is because in this cases the parameter is just an address. If you pass an object by value, the compiler creates a copy of the object on the stack - and therefore needs all the information of the object, e.g. how many bytes it occupies, whether it has a copy constructor and so on.
Jerome wrote: > Hi all, > > I'm trying to use forward declaration with value class but I don't succeed > in compiling my (quite simple) sample code. > This is my code I'm trying to compile (Visual Studio 2003) > > namespace managedDll > { > public __value class VecDouble; > public __value class VecFloat > { > public: > void SetValue(VecDou ble vec) > > { > // TODO > } > > }; > > public __value class VecDouble > { > > public: > void SetValue(VecFlo at vec) > > { > // TODO > } > > }; > } > > I've got the following error when compiling: > error C2027: use of undefined type 'managedDll::Ve cDouble' > > Every think work fine if my SetValues methods have the signature (Vec(Double > | Float) &vec). > The problem is that putting a '&' is not logical because I want to call > methods from C# code and with this signature I should write the following > code > > VecDouble vec = new VecDouble(); > vecFloat.SetVal ue(ref vec); > > Instead I want to call my methods in this way: > vecFloat.SetVal ue(new VecDouble()) > The first solution is not acceptable !. > > Does anyone encounter the same problem ? > > Great thanks. > Jerome > >
It works !
I try so much things that I don't try the simple one ...
Great thanks !
"James Park" <jp**********@S paMMEhotmail.co m> a écrit dans le message de
news:uO******** ******@tk2msftn gp13.phx.gbl... How about something like this: namespace managedDll { public __value class VecDouble; public __value class VecFloat { public: void SetValue(VecDou ble vec); };
public __value class VecDouble { public: void SetValue(VecFlo at vec) { // TODO } };
void VecFloat::SetVa lue(VecDouble vec) { // TODO } }
"Jerome" <jl****@NOSPAMm c.com> wrote in message news:Oc******** ******@TK2MSFTN GP10.phx.gbl...I know that ... and that's why I think there's a problem with managed C++ language. It's not acceptable that a method you think taking a parameter as 'In' must be signed by 'ref' Of course the problem does not exists with reference class.
I'm still dreaming of a magic attribute or magic compilation option ... who knows ? ... certainly Microsoft developpers ... Anyone from Microsoft Visual Studio team to solve my issue or explain why it can't be possible ???
"Eckart Haug" <Ec*********@lu k.de> a écrit dans le message de news:db******** **@aftlinux2.we rdohl.aft-werdohl.de... Forward declaration by definition only works with pointers (VecDouble* vec) and refenences (VecDouble& vec). This is because in this cases the parameter is just an address. If you pass an object by value, the compiler creates a copy of the object on the stack - and therefore needs all the information of the object, e.g. how many bytes it occupies, whether it has a copy constructor and so on.
Jerome wrote: > Hi all, > > I'm trying to use forward declaration with value class but I don't succeed > in compiling my (quite simple) sample code. > This is my code I'm trying to compile (Visual Studio 2003) > > namespace managedDll > { > public __value class VecDouble; > public __value class VecFloat > { > public: > void SetValue(VecDou ble vec) > > { > // TODO > } > > }; > > public __value class VecDouble > { > > public: > void SetValue(VecFlo at vec) > > { > // TODO > } > > }; > } > > I've got the following error when compiling: > error C2027: use of undefined type 'managedDll::Ve cDouble' > > Every think work fine if my SetValues methods have the signature (Vec(Double > | Float) &vec). > The problem is that putting a '&' is not logical because I want to
call > methods from C# code and with this signature I should write the following > code > > VecDouble vec = new VecDouble(); > vecFloat.SetVal ue(ref vec); > > Instead I want to call my methods in this way: > vecFloat.SetVal ue(new VecDouble()) > The first solution is not acceptable !. > > Does anyone encounter the same problem ? > > Great thanks. > Jerome > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mjm |
last post by:
Folks,
Please help me with the following problems:
********************************************
1. I have a class template
template<class Base> class Matrix : public Base { /* .... */ }
|
by: jobseeker |
last post by:
From: jobseeker95479@yahoo.com (jobseeker)
Newsgroups: comp.lang.c++.moderated
Subject: template and forward declaration
NNTP-Posting-Host: 131.233.150.22
I have defined a class that contains a data member of a function type.
The signature of the function type take a pointer of the class itself
as a parameter:
class Softkey; // forward declaration
|
by: Alan Lee |
last post by:
Hi i am writing a small simulation for a bunch of atoms jumping around on a
surface. I know i am a crappy programmer since i am not very familiar with
object oriented languages. I am woindering if anyone can tell me why my
forward class declarations not working.
the member function findpaths can't seem to access the class Board
when I try to pass it a board object by value.
I put the Board class latrerbut also put in a forward...
|
by: aleko |
last post by:
This applies equally to function prototypes. Why do we have to tell the
compiler twice? Other modern compiled languages don't have this
requirement.
Just curious,
Aleko
|
by: Plok Plokowitsch |
last post by:
After over a decade of programming in C++ I seem to have missed some
substantial point (mental note: am I getting too old for this?). A
little bit of help would be *very* appreciated.
I'm trying to gather various different classes into a common namespace
using typedefs:
class QWidget {};
class MyListview {};
namespace gui
| |
by: Michael Sgier |
last post by:
Hello
with the original code below I get the error:
"forward declaration of `struct CPlayer'"
class CPlayer; // what does this do? Instantiate the class CPlayer?
// what's a forward declaration?
class CEnemy : public CEntity
{
public:
|
by: mark.moore |
last post by:
I know this has been asked before, but I just can't find the answer in
the sea of hits...
How do you forward declare a class that is *not* paramaterized, but is
based on a template class?
Here's what I thought should work, but apparently doesn't:
class Foo;
void f1(Foo* p)
|
by: Hunk |
last post by:
Hi
I have a question on usage of forward declarations of templates. While
searching through this group , people suggested using forward
declarations and typedefs for templates as
// in myfile.h
template<typename T,typename R>
class some_class;
|
by: Steve |
last post by:
Hi,
I always though to return an instance of a class by value, it had to be
defined - i.e. forward declaration isn't good enough?
Consider the following code snippet:
class RGBA;
class Colour
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |