88 lines
1.5 KiB
C++
88 lines
1.5 KiB
C++
#include "foo.h"
|
|
#include <iostream>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
int print_something(const char *message)
|
|
{
|
|
std::cout << "MESSAGE1: " << message << std::endl;
|
|
return strlen(message);
|
|
}
|
|
|
|
int print_something_else(const char *message2)
|
|
{
|
|
std::cout << "MESSAGE2: " << message2 << std::endl;
|
|
return strlen(message2);
|
|
}
|
|
|
|
int get_int_from_string(const char *from_string)
|
|
{
|
|
return atoi(from_string);
|
|
}
|
|
|
|
int get_int_from_float(double from_float)
|
|
{
|
|
return (int) from_float;
|
|
}
|
|
|
|
|
|
std::string SomeObject::staticData = std::string("Hello Static World!");
|
|
|
|
int SomeObject::get_int (const char *from_string)
|
|
{
|
|
return atoi(from_string);
|
|
}
|
|
|
|
int SomeObject::get_int (double from_float)
|
|
{
|
|
return (int) from_float;
|
|
}
|
|
|
|
int SomeObject::instance_count = 0;
|
|
|
|
class HiddenClass : public Bar
|
|
{
|
|
};
|
|
|
|
|
|
Foo*
|
|
get_hidden_subclass_pointer ()
|
|
{
|
|
return new HiddenClass;
|
|
}
|
|
|
|
|
|
static SomeObject *g_someObject = 0;
|
|
|
|
// Transfer ownership of 'obj' to the library
|
|
void store_some_object(SomeObject *obj)
|
|
{
|
|
delete g_someObject;
|
|
g_someObject = obj;
|
|
}
|
|
|
|
// Invokes the virtual method in the stored SomeObject
|
|
std::string invoke_some_object_get_prefix()
|
|
{
|
|
if (g_someObject)
|
|
return g_someObject->get_prefix();
|
|
else
|
|
return std::string();
|
|
}
|
|
|
|
// Transfer ownership of 'obj' away from the library
|
|
SomeObject* take_some_object()
|
|
{
|
|
SomeObject *retval = g_someObject;
|
|
g_someObject = 0;
|
|
return retval;
|
|
}
|
|
|
|
// Deletes the contained object, if any
|
|
void delete_some_object()
|
|
{
|
|
delete g_someObject;
|
|
g_someObject = 0;
|
|
}
|
|
|