Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LIBCACHE.H
- #pragma once
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef struct Cache Cache;
- int CreateCache(Cache *cache);
- int DestroyCache(Cache *cache);
- #ifdef __cplusplus
- }
- #endif
- CACHE.CPP
- #include "libcache.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- int CreateCache(Cache *cache)
- {
- std::cout << "AAA: " << cache << std::endl;
- cache = new Cache();
- std::cout << "BBB: " << cache << std::endl;
- return 0;
- }
- int DestroyCache(Cache *cache)
- {
- delete cache;
- cache = NULL;
- return 0;
- }
- #ifdef __cplusplus
- }
- #endif
- MAIN.C
- int main(int argc, char *argv[])
- {
- Cache *cache = NULL;
- CreateCache(cache);
- printf("%s - %p\n", "Cache created", cache);
- //DestroyCache(cache);
- printf("%s - %p\n", "Cache destroyed", cache);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement