473,835 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C Structure Inheritance

sri
Dear All,

I am trying to inherit C Structure interface and its implementation
developed by third party. I would like to provide a wrapper kind of
class to my user. For instance,

mapctx.h
-------------

struct MAPCTX
{
......
}

mapctx.c
-------------
void InitMapctx(long xsize)
{
xsize = 7;
}

MyCpp.h
-------------
class MyMapCtx : public MAPCTX
{
void XInitMapContext (long XSize)
{
InitMapctx(XSiz e);
}
};

When I compile this code in Microsoft C++ compiler it is giving the
following errors

error C2143: syntax error : missing ')' before 'constant'
error C2143: syntax error : missing ';' before 'constant'
error C2059: syntax error : 'constant'
error C2059: syntax error : ')'
error C2334: unexpected token(s) preceding '{'; skipping apparent
function body

As per my observation parameter XSize is causing to list these errors.
Please let me know why this is going wrong.

With Regards,
Sri

Mar 28 '07 #1
2 6386
sri
I noticed the cause, the problem is XSize is already defined as a
constant in the third party library.

With Regards,
Sri

On Mar 28, 6:52 pm, "sri" <srinivasarao_m ot...@yahoo.com wrote:
Dear All,

I am trying to inheritCStructu reinterface and its implementation
developed by third party. I would like to provide a wrapper kind of
class to my user. For instance,

mapctx.h
-------------

struct MAPCTX
{
.....

}

mapctx.c
-------------
void InitMapctx(long xsize)
{
xsize = 7;

}

MyCpp.h
-------------
class MyMapCtx : public MAPCTX
{
void XInitMapContext (long XSize)
{
InitMapctx(XSiz e);
}

};

When I compile this code in Microsoft C++ compiler it is giving the
following errors

error C2143: syntax error : missing ')' before 'constant'
error C2143: syntax error : missing ';' before 'constant'
error C2059: syntax error : 'constant'
error C2059: syntax error : ')'
error C2334: unexpected token(s) preceding '{'; skipping apparent
function body

As per my observation parameter XSize is causing to list these errors.
Please let me know why this is going wrong.

With Regards,
Sri

Mar 28 '07 #2
sri wrote:
I am trying to inherit C Structure interface and its implementation
developed by third party. I would like to provide a wrapper kind of
class to my user. For instance,

mapctx.h
-------------

struct MAPCTX
{
.....
}
A semicolon is missing here.
>
mapctx.c
-------------
void InitMapctx(long xsize)
{
xsize = 7;
}
This function has no effect whatsoever. A good link-based optimizer
is likely to take it out completely.

To give this function the desired effect, pass the arg by reference.
>
MyCpp.h
-------------
class MyMapCtx : public MAPCTX
{
void XInitMapContext (long XSize)
{
InitMapctx(XSiz e);
}
This member function has no effect either. Same comment as above.
};

When I compile this code in Microsoft C++ compiler it is giving the
following errors

error C2143: syntax error : missing ')' before 'constant'
On which line?
error C2143: syntax error : missing ';' before 'constant'
Again, on which line?
error C2059: syntax error : 'constant'
error C2059: syntax error : ')'
error C2334: unexpected token(s) preceding '{'; skipping apparent
function body

As per my observation parameter XSize is causing to list these errors.
Please let me know why this is going wrong.
Could it be that 'XSize' is actually a type name? What if you changed
the name of the argument in the 'XInitMapContex t' member?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Mar 28 '07 #3

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

Similar topics

4
9246
by: shane | last post by:
From searching around, Ive seen this question asked numerous times, but havent seen a usable answer unfortuantly. What Im trying to do is something I would have thought would be quite common, but there just seems to be no information on the topic that I can find. Basically I need to store a directory structure in memory, from a flat list of files and paths. ie given: C:\dir\dir1\abc.txt C:\dir\toop.txt
18
1813
by: Anand Buddhdev | last post by:
Hi everyone, I'm a C newbie, so please be gentle. I have a program that defines the following things: typedef union { unsigned int I; unsigned char b; } dword;
3
1406
by: project | last post by:
Hi every body, Any body can help me the following doubts? 1. what is constructor? 2. what is destructor? 3. what is overriding function. 4. different between structure and array 5. what is objected oriented
12
2435
by: Sam Kong | last post by:
Hi, JavaScript hides its memory structure. I know that numbers, booleans, null and undefined are value types (value is directed saved in a variable). I want to know: - How JavaScript distinguishes value types from reference types by seeing the variable content?
11
2356
by: aaragon | last post by:
Hi everyone. I'm trying to write a class with policy based design (Alexandrescu's Modern C++ Design). I'm not a programmer but an engineer so this is kind of hard for me. Through the use of policies, I want to customize the structure of a class. The idea is to investigate the use of several data structures. One option would be the use of the boost dynamic bitset. Another would be the use of the std::vector. I obtained some code that...
8
2153
by: Vj | last post by:
Hi all, I'm finding some people in my company defining a version number as a field to some structure. The sample code goes as follows: typedef enum _params_ver_ { UNDEF = 0, VERSION_1,
3
18589
by: darkenergy | last post by:
Hi all, I want to do a similar thing as class inheritance in C++, but with structures in C. I have a structure A, and I want to define a second structure B (in different .h/.c files), which has the same variables as A plus some additional ones. I want to use the existing functions that manipulate and create A also for B and, using some new functions, add the bits about the additional variables. If possible, it will not be necessary to...
0
422
by: Joe HM | last post by:
Hello - I have a *.dll that was compiled from Ada. The following declaration and Structure is working ... Declare Sub XXX Lib "X.dll" (ByRef XState As XStructure) <StructLayout(LayoutKind.Explicit)_ Structure XStructure <FieldOffset(0)Dim A As Single
5
1566
by: jc | last post by:
RE: Two Classes with the same Data Structure.. saving code? Inheriting a structure? I have two classes. One in Inherits System.Collections.CollectionBase, the other does not, but they both have the identical structure and properties. the only difference between them is there methods and that one is a collection class and the other is not. currently the code starts like this:
1
1640
by: Arthur Dent | last post by:
Hello all... I have a method which returns a KeyValuePair(Of Long, String). I would like to make an alias for that, so instead of typing KeyValuePair(Of Long, String) everywhere I could just type my alias instead. First I thought inheritance, ... Structure MyPair Inherits KeyValuePair(Of Long, String), but you can't inherit structures. Next I thought Lambdas, but I don't think those really apply here.
0
10815
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
10526
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...
1
10563
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9348
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, 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...
1
7770
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
6970
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();...
0
5640
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...
0
5808
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3999
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.