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

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(XSize);
}
};

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 6371
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_mot...@yahoo.comwrote:
Dear All,

I am trying to inheritCStructureinterface 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(XSize);
}

};

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(XSize);
}
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 'XInitMapContext' 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
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,...
18
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
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...
12
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...
11
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...
8
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
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...
0
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) ...
5
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...
1
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...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...
0
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
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,...

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.