Boost logo

Boost Users :

Subject: [Boost-users] Using C++ class with namespace in C
From: Somostetoi Kilato (somostetoikilato_at_[hidden])
Date: 2013-04-16 05:04:06


Hi,

maybe it is not the best place to ask but at this moment I have no other
idea where to go. This question is just a preamble for all the comming,
BOOST related, questions of mine.

So, I have a C++ class, the Apple, at the moment in the std namespace:

class Apple {
 public:
  Apple();
  void eat_an_apple(int p_bites);
 private:
  int bites; // number of bites to eat an apple
};
I have a C application, an apple picker, first the header:

typedef void CApple;
#ifdef __cplusplus
extern "C" {
#endif
CApple* pick_an_apple();
void eat_an_apple(const CApple *p_the_apple, int p_bites);
void wash_your_hands(CApple *p_the_apple);
#ifdef __cplusplus
} // extern "C"
#endif
and the code, too:

#include <stdio.h>
#include "ApplePicker.hh"
int main() {
 CApple *the_apple = NULL;
 the_apple = pick_an_apple();
 eat_an_apple(the_apple, 9);
 wash_your_hands(the_apple);
 the_apple = NULL;
 return 0;
}

My question is, if I want to move my Apple class in a custom namespace,
garden, how must I modify my C header and code file?

Thank you and all the best,
Kilato Somostetoi



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net