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

using preprocessors - help!!

I have a class which only purpose is to provide services to a variety
of classes in other files. The 'manipulator' class is aware of the
other classes only because the header files have been include in its
header file. However, there are times when some of the other classes
are not and will not be dealt with, thus the need to include the header
files does not arrive. To handle this, I have used compiler
preprocessors to prevent the unneeded header files and method
declarations / implementations to be compiled, here is an example:

--- popeye.hpp ---
#ifndef POPEYE_HPP
#define POPEYE_HPP
class popeye{ /*the whole enchilada goes here */};

--- mikey.hpp ---
#ifndef MIKEYMOUSE_HPP
#define MIKEYMOUSE_HPP
class mikey{ /*more cheese senior?*/ };

--- donal.hpp ---
#ifndef DONALDUCK_HPP
#define DONALDUCK_HPP
class duck{ /* para bailar la banba */};

--- manipulator.hpp ---
#ifndef MANIPULATOR_HPP
#define MANIPULATOR_HPP
#ifdef POPEYE_HPP
#include "popeye.hpp"
#endif
#ifdef MIKEYMOUSE_HPP
#include "mikey.hpp"
#endif

#ifdef DONALDUCK_HPP
#include "donal.hpp"
#endif

class manipulator{
private:
..........
protected:
..........
public:
..........
#ifdef POPEYE_HPP
void handle_popeye(const popeye&);
#endif

#ifdef MIKEMOUSE_HPP
void handle_mikey(const mikey&);
#endif

#ifdef DONALDUCK_HPP
void handle_duck(const duck&);
#endif
.........
};
#ifdef POPEYE_HPP
void manipulator::handle_popeye(const popeye& p){/*...*/}
#endif
#ifdef MIKEMOUSE_HPP
void manipulator::handle_mikey(const mikey& p){/*...*/}
#endif
#ifdef DONALDUCK_HPP
void manipulator::handle_duck(const duck& p){/*...*/}
#endif
--- main.cpp --
#include "popeye.hpp"
#include "manipulator"

int main(){
popeye p;
manipulator m;
m.handle_popeye(p); //<<== segmentation fault
return 0;
}

My question is: why is it that if I remove the conditional
preprocessors I don't get a segmentation fault?
T. I. A. F.
(Thank In Advance Folks)

Dec 18 '05 #1
4 1108
In article <11**********************@g14g2000cwa.googlegroups .com>,
Jamiil <ja******@netscape.net> wrote:
I have a class which only purpose is to provide services to a variety
of classes in other files.
The C language does not have any notion of "class".
class popeye{ /*the whole enchilada goes here */};


That appears to be a C++ question. Please ask in comp.lang.c++ .
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
Dec 18 '05 #2
Jamiil wrote:
I have a class which only purpose is to provide services to a variety
of classes in other files. The 'manipulator' class is aware of the


This is a group about C which does not have these "classes" you speak
of. Try comp.lang.c++.

Robert Gamble

Dec 18 '05 #3
Thanks folks for your prompt response.
Yes, I know that, but the question is about compiler preprocessors not
about C++; it just happens to be in an hpp file. With a little
imagination one could very quickly convert the example to a C program.
Thanks anyway.

Robert Gamble wrote:
Jamiil wrote:
I have a class which only purpose is to provide services to a variety
of classes in other files. The 'manipulator' class is aware of the


This is a group about C which does not have these "classes" you speak
of. Try comp.lang.c++.

Robert Gamble


Dec 19 '05 #4
"Jamiil" <ja******@netscape.net> writes:
Robert Gamble wrote:
Jamiil wrote:
> I have a class which only purpose is to provide services to a variety
> of classes in other files. The 'manipulator' class is aware of the


This is a group about C which does not have these "classes" you speak
of. Try comp.lang.c++.

Thanks folks for your prompt response.
Yes, I know that, but the question is about compiler preprocessors not
about C++; it just happens to be in an hpp file. With a little
imagination one could very quickly convert the example to a C program.

Thanks anyway.


Please don't top-post. Your response goes below any quoted text.

You posted C++ code. The folks in comp.lang.c++ can help you with it.

If you want help with a C code, you'll need to post some; we won't
convert it for you.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 19 '05 #5

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

Similar topics

6
by: Clara | last post by:
Hi,... I meant to write an application where there is a button in a window and when you click on the button, it will open a new window, but I want the first window to close, replaced by the second...
0
by: Timothy V | last post by:
Hi, I'm having trouble working this out and was wondering if anyone could help me. I have a query: SELECT 1 AS Tag, NULL AS Parent, classID AS , className AS FROM Classes FOR XML EXPLICIT;
0
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
6
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
1
by: cranker | last post by:
No matter how I fill in parameters for the CreateProcess API, I keep getting a NullReference exception thrown at me when my code executes It's driving me nuts! Can anyone help?
1
by: blinkrebel | last post by:
Hello I need some help implementing the game of blackjack using the xturtle package. the instructions can be found at http://katie.luther.edu/moodle/file.php/2387/BlackJack.pdf and .gif's...
2
by: CharlesHawk | last post by:
HI i am working on a Project where i have to send a string using Sessions to the next page this is working gud for now But i can convert session to a string the .ToString(); and the...
1
by: jrw133 | last post by:
So i was given this program in class. i am supposed to create a four-function calculator for fractions using a fraction class. Heres what the requirements are:create a member function for each of...
0
by: Vicky77 | last post by:
Hi, I need help on calling a program or a command line compiler to compile a program written in a textbox of my IDE. Ok, there's a button called build. If the button is clicked by the user, the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.