Computing.Net > Forums > Programming > conversion of struct into class

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

conversion of struct into class

Reply to Message Icon

Name: priti
Date: August 10, 2003 at 19:23:16 Pacific
OS: win xp
CPU/Ram: celeron
Comment:

Hi,
How can I convert this struct structure into class of c++?

struct rwlock
{
#ifdef RWLOCK_DEBUG
pthread_key_t key;
#endif
pthread_mutex_t lock;
pthread_cond_t rcond;
pthread_cond_t wcond;
int lock_count;
int waiting_writers;
};

#ifdef RWLOCK_DEBUG
struct LockPos
{
int type;
char *file;
int line;
pthread_key_t key;
};
#include

struct rwlock;
typedef struct rwlock *rwlock_t;

#define RWLOCK_DEBUG 2

void rwlock_Init(rwlock_t rwl);
rwlock_t rwlock_InitFull(void);

void rwlock_WriteUnlockD(rwlock_t rwl, char *f, int l);
void rwlock_ReadLock(rwlock_t rwl);
void rwlock_ReadUnlock(rwlock_t rwl);

Any help would be greatly appreciate.
Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: August 10, 2003 at 20:05:27 Pacific
Reply:

basically you change the word 'struct' to 'class' and add some methods.


0

Response Number 2
Name: Infinite Recursion
Date: August 10, 2003 at 20:25:19 Pacific
Reply:

That was easy... wasn't it? :)
Or you could keep the struct and add the class syntax... methods and such... and save it into a .h or something.


0

Response Number 3
Name: Rolos
Date: August 10, 2003 at 23:48:01 Pacific
Reply:

Might I add on. If you're planning on keeping all of your members public, you may as well leave it as a structure. We can't tell you how to convert it to a class, because first off, we don't know what members you want private and what members you want public.

- Rolos


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


How do I set up web direc... systray callback



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: conversion of struct into class

Conversion of C++ into Fortran www.computing.net/answers/programming/conversion-of-c-into-fortran/8003.html

Arrays of Structs www.computing.net/answers/programming/arrays-of-structs/6478.html

UML: class diagram vs conceptual www.computing.net/answers/programming/uml-class-diagram-vs-conceptual-/11564.html