473,748 Members | 9,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forward declaration again

Thanx for the quick reply. Your suggestion would mean that I'd have to add a C# reference to any C++ module
that includes the C++ header. There's lots of them and I'd (for the moment) like to have the C++ <-> C#
interface encapsulated in one C++ module.

Vladimir Nesterovsky wrote:
You can add your C# assembly in a project's references thus you may not import it explicitly.
--
Vladimir Nesterovsky
e-mail: vl******@nester ovsky-bros.com
home: http://www.nesterovsky-bros.com

I'm working with C# objects from managed C++ using the gcroot template.
There'a a C++ header containing the definition of a C++ class:

#using <mscorlib.dll >
#include <vcclr.h>
#using <CSharpModule.d ll>

class CPlusPlusClass
{
....

gcroot<TLNameSp ace::SubNameSpa ce::SomeType*> _csharpInstance ;

....
}
and a C++ source file containing the class definition
#include "CPlusPlusClass .h"
using namespace TLNameSpace::Su bNameSpace;
void CPlusPlusClass: :createCSharp()
{
gcroot = new SomeType();
}

void CPlusPlusClass: :doSomething()
{
gcroot->someCSharpMeth od();
}

.....
In this example, I need the #using <CSharpModule.d ll> directive in the C++ header. One way to avoid this is
to split CPlusPlusClass into CPlusPlusInterf ace and CPlusPlus Implementation.
A more elegant technique in C++ would be a forward declaration for TLNameSpace::Su bNameSpace::Som eType in
the C++ header. However, I didn't find out how to do this.
The most promising try was

namespace TLNameSpace {
namespace SubNameSpace {
__gcc class SomeType;
}
}

At least the header compiled. On the #using <CSharpModule.d ll> line, I got an 'already defined' error.
Obviously C++ and C# namespaces are just a little bit the same ....

My question is:

- Is there a way to do the forward declaration described above ?
I'd appreciate any hint/solution for this


Nov 17 '05 #1
0 914

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

Similar topics

3
5467
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 { /* .... */ }
6
5213
by: Steven T. Hatton | last post by:
Should I be able to forward declare something from a namespace different from the current one? For example the following code compiles: //testdriver.hpp #ifndef TESTDRIVER_HPP #define TESTDRIVER_HPP #include <ostream> namespace ns_testdriver{ using std::ostream;
2
4520
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
3
20610
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:
3
1981
by: Libertadrian | last post by:
Hi again, Maybe I missed something, but I cannot do a forward declaration in managed C++. By doing: namespace Namespace {
1
5709
by: HappyHippy | last post by:
Hi, I have a question about forward declaration of classes. First of all, a simple working example, which compiles and works with no problems. ///file class_a.h:/ #ifndef __CLASS_A_H__ #define __CLASS_A_H__
23
3856
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)
6
8618
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;
7
5083
by: RedLars | last post by:
Need some help with a couple of questions. Previously I have seen this declaration; struct Student { int age; char name; }; and this definition of an object; struct Student stud;
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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,...
0
9548
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9249
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 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...
1
6796
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 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...
0
6076
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();...
1
3315
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
2
2787
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.