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

style question

When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that dynamically
allocate/free the struct and then I create a bunch of functions that operate
on the struct. Example:

typedef struct ccHashTab
{
.....
} ccHashTab;

ccHashTab * ccMakeHash(unsigned int size, hash h, comp c);
void ccFreeHashTab(ccHashTab *table);
void *ccHashFindSym(ccHashTab *table, void *symbol);
......

This is a bit the object-oriented way, because I never touch the struct
members directly, only inside the hash functions.
Now I'm wondering if this is a style that other C programmers use in their
work or if they're using something different. I just want to know some
opinions, maybe I'll get some new insights.
Nov 13 '05 #1
23 2673

"Serve La" <ik@veranderhetal.com> wrote in message
news:bj**********@news3.tilbu1.nb.home.nl...
When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that dynamically allocate/free the struct and then I create a bunch of functions that operate on the struct. Example:

typedef struct ccHashTab
{
....
} ccHashTab;

ccHashTab * ccMakeHash(unsigned int size, hash h, comp c);
void ccFreeHashTab(ccHashTab *table);
void *ccHashFindSym(ccHashTab *table, void *symbol);
.....

This is a bit the object-oriented way, because I never touch the struct
members directly, only inside the hash functions.
Now I'm wondering if this is a style that other C programmers use in their
work or if they're using something different. I just want to know some
opinions, maybe I'll get some new insights.


to hide the details of struct ccHashTab and make it a bit more OO I would do
something like the following(especially if you don't access ccHashTab
members directly)

in hashtab.h

typedef struct ccHashTab * ccHashTabRef;

ccHashTabRef ccMakeHash(unsigned int size, hash h, comp c);
void ccFreeHashTab(ccHashTabRef table);
void *ccHashFindSym(ccHashTabRef table, void *symbol);

in hashtab.c
#include "hashtab.h"
struct ccHashTab
{
....
}

ccHashTabRef ccMakeHash(unsigned int size, hash h, comp c)
{
....
}
void ccFreeHashTab(ccHashTabRef table)
{
....
}
void *ccHashFindSym(ccHashTabRef table, void *symbol)
{
....
}
Nov 13 '05 #2
Serve La wrote:
When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that dynamically
allocate/free the struct and then I create a bunch of functions that operate
on the struct. Example:
typedef struct ccHashTab {
// ...
} ccHashTab;

ccHashTab ccHashTab_create(unsigned int size, hash h, comp c);
void ccHashTab_destroy(const ccHashTab* pTable);
void* ccHashTab_find(ccHashTab* pTable, void* pSymbol);
.....

This is a bit the object-oriented way
because I never touch the struct members directly,
only inside the hash functions.
Now I'm wondering if this is a style
that other C programmers use in their work
or if they're using something different.
I just want to know some opinions, maybe I'll get some new insights.


Try to avoid functions that return a pointer to memory
allocated from the free store.

Nov 13 '05 #3
Serve La <ik@veranderhetal.com> wrote:
When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that dynamically
allocate/free the struct and then I create a bunch of functions that operate
on the struct. Example:

typedef struct ccHashTab
{
....
} ccHashTab;

ccHashTab * ccMakeHash(unsigned int size, hash h, comp c);
void ccFreeHashTab(ccHashTab *table);
void *ccHashFindSym(ccHashTab *table, void *symbol);
.....

This is a bit the object-oriented way, because I never touch the struct
members directly, only inside the hash functions.
Now I'm wondering if this is a style that other C programmers use in their
work or if they're using something different. I just want to know some
opinions, maybe I'll get some new insights.


Yeah, that's fairly common. If you want to stop the user from accessing
the internals of the structs, you can declare them incompletely in the
header file:

typedef struct ccHashTab ccHashTab;

then fully define the struct in the .c file that implements the hash
table:

struct ccHashTab {
...
}

It's not a good idea to use a typedef to hide the fact that it's a
pointer (which you haven't done anyway, but one of the other replies in
this thread does) - if the user knows it's a pointer they know they can
safely do things like assign it to a void * and back again, and compare
the constructor function return value against NULL to check for errors.

- Kevin.

Nov 13 '05 #4

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:3F**************@jpl.nasa.gov...
Try to avoid functions that return a pointer to memory
allocated from the free store.


That is IMO only good for simple structs where all data is known at
compile-time. If a struct gets complicated I don't want to put the burden on
allocating the struct on a client programmer. Chances are she forgets a NULL
check somewhere or does it wrong.
What I do now is create an extra function ccConstructHashTab that performs
the role of a constructor. This function doesn't care if the pointer is
pointing to dynamic memory or not.
But most of my structs are too complicated for static storage
Nov 13 '05 #5
Serve La wrote:
E. Robert Tisdale wrote:
Try to avoid functions that return a pointer to memory
allocated from the free store.


That is, IMO, only good for simple structs
where all data is known at compile-time.
If a struct gets complicated,
I don't want to put the burden on allocating the struct
on a client programmer.
Chances are she forgets a NULL check somewhere or does it wrong.
What I do now is create an extra function ccConstructHashTab
that performs the role of a constructor. This function doesn't care
if the pointer is pointing to dynamic memory or not.
But most of my structs are too complicated for static storage.


You are confused. A pseudo constructor like

ccHashTab ccHashTab_create(unsigned int size, hash h, comp c);

places *no* "burden" on the application program.
It works well no matter how complicated the data structure.

People have been doing this sort of thing for a very long time.
Take a look, for example, at The ANSI C Numerical Class Library

http://www.netwood.net/~edwin/svmtl/

It allows you to construct vector and matrix objects from either
automatic or free storage. You might also look at
The GNU Scientific Library (GSL)

http://sources.redhat.com/gsl/

Nov 13 '05 #6

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:3F**************@jpl.nasa.gov...
ccHashTab ccHashTab_create(unsigned int size, hash h, comp c);

places *no* "burden" on the application program.
It works well no matter how complicated the data structure.

People have been doing this sort of thing for a very long time.
Take a look, for example, at The ANSI C Numerical Class Library

http://www.netwood.net/~edwin/svmtl/

It allows you to construct vector and matrix objects from either
automatic or free storage. You might also look at
The GNU Scientific Library (GSL)

http://sources.redhat.com/gsl/


I can't unzip those, could you give an example?

Here's a fairly complicated struct that I now allocate in a function:

typedef struct Inner
{
ITypeInfo *info;
TYPEATTR *attr;
BSTR name;
int index;
} Inner;

typedef struct SomeStruct
{
GUID libid;
ITypeLib *lib;
Inner *info;
UINT ntypeinfo;
BSTR filename;
BSTR helpstring;
BSTR helpfilename;
UINT currentiter;
} SomeStruct;
Nov 13 '05 #7
"Serve La" <ik@veranderhetal.com> wrote:
When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that dynamically
allocate/free the struct and then I create a bunch of functions that operate
on the struct. Example:

typedef struct ccHashTab
{
....
} ccHashTab;
This typedef is unnecessary and doesn't really do anything useful,
except confuse C++ people (in C++ struct ___ doesn't create a new name
space, the "struct" can be dropped.)
ccHashTab * ccMakeHash(unsigned int size, hash h, comp c);
void ccFreeHashTab(ccHashTab *table);
void *ccHashFindSym(ccHashTab *table, void *symbol);
.....
I do it this way:

/* constructor/destructor */
struct ccHashTab * newCcHash (unsigned int size, int (* keyFn)(void
*));
int destroyCcHash (struct ccHashTab *table);

int clearCcHash (struct ccHashTab *table);
int iterateCcHash (struct ccHashTab *table,
int (* cb) (void * ctx, void * entry), void * ctx);
int insertCcHash (struct ccHashTab *table, void * entry);
int deleteCcHash (struct ccHashTab *table, void * entry);
void * findCcHash (struct ccHashTab *table, void * entry);
/* and other "methods" */

is put in hash.h, and the struct ccHashTab definition is only in the
hash module. Knowing that its a pointer to a struct doesn't really
ruin its opaqueness, if you don't know the structure contents.
However, it makes it clear that you cannot copy it without a copy
method.

One of the things that's always bothered me is that I cannot put
"const" on the table declaration in the findCcHash function. The
reason is that you are returning a pointer that table is pointing to,
and thus the compiler cannot figure out whether or not you might
modify its contents.
This is a bit the object-oriented way, because I never touch the struct
members directly, only inside the hash functions.


Of course the burning question, then is, why not use C++ instead of C
then?

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
Nov 13 '05 #8
"E. Robert Tisdale" wrote:
Serve La wrote:
When I write a medium to large sized C application I tend to
create structures first, then makeStruct and freeStruct
functions that dynamically allocate/free the struct and then
I create a bunch of functions that operate on the struct.
Example:

typedef struct ccHashTab {
// ...
} ccHashTab;

ccHashTab ccHashTab_create(unsigned int size, hash h, comp c);
void ccHashTab_destroy(const ccHashTab* pTable);
void* ccHashTab_find(ccHashTab* pTable, void* pSymbol);
.....

This is a bit the object-oriented way because I never touch
the struct members directly, only inside the hash functions.
Now I'm wondering if this is a style that other C programmers
use in their work or if they're using something different.
I just want to know some opinions, maybe I'll get some new
insights.


Try to avoid functions that return a pointer to memory
allocated from the free store.


This is nonsense advice, especially in this context.

To the OP: You need to evaluate the advice given in c.l.c,
dependant on the advisor. In general advice from ERT is likely to
be valueless, off-topic, and wrong.

Your general approach is worthwhile. It is also advisable to
find ways to hide the actual construction of these entities, so
that you are free to alter the implementation without affecting
the usage. For an example in my style see:

<http://cbfalconer.home.att.net/download/hashlib.zip>

--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
Nov 13 '05 #9

"Paul Hsieh" <qe*@pobox.com> wrote in message
news:79**************************@posting.google.c om...
This is a bit the object-oriented way, because I never touch the struct
members directly, only inside the hash functions.


Of course the burning question, then is, why not use C++ instead of C
then?


Huh?
Because OO is not bound to C++
Nov 13 '05 #10

"Serve La" <ik@veranderhetal.com> wrote in message
Of course the burning question, then is, why not use C++ instead of > >
C then?
Huh?
Because OO is not bound to C++

C++ classes are only really useful when you have inheritance relationships
between them. If you are not going to base your design on a class hierarchy,
a C implementation will generally be cleaner and easier to understand and
maintain.
Nov 13 '05 #11
Serve La wrote:
E. Robert Tisdale wrote:
ccHashTab ccHashTab_create(unsigned int size, hash h, comp c);

places *no* "burden" on the application program.
It works well no matter how complicated the data structure.

People have been doing this sort of thing for a very long time.
Take a look, for example, at The ANSI C Numerical Class Library

http://www.netwood.net/~edwin/svmtl/

It allows you to construct vector and matrix objects from either
automatic or free storage. You might also look at
The GNU Scientific Library (GSL)

http://sources.redhat.com/gsl/
I can't unzip those.


They are compressed UNIX tape archives.
You can probably use Stuffit

http://www.stuffit.com/win/expander/index.html

to uncompress and extract the directory.
Could you give an example?

Here's a fairly complicated struct that I now allocate in a function:

typedef struct Inner {
ITypeInfo *info;
TYPEATTR *attr;
BSTR name;
int index;
} Inner;

typedef struct SomeStruct {
GUID libid;
ITypeLib *lib;
Inner *info;
UINT ntypeinfo;
BSTR filename;
BSTR helpstring;
BSTR helpfilename;
UINT currentiter;
} SomeStruct;

#ifdef NCL_REVEAL
/* Reveal type definitions after applications are thoroughly tested. */

typedef struct { /* submatrix class definition */
/* private: */
ncl_dchandle H;
ncl_offset O;
ncl_extent N1;
ncl_stride S1;
ncl_extent N2;
ncl_stride S2;
ncl_______ _;
} ncl_dcsubmatrix;
/* A submatrix does not own the array storage that it references. */
/* It does not allocate any array storage when it is constructed */
/* nor does it deallocate any array storage when it is destroyed. */

#else /* NCL_REVEAL */
/* Conceal type definitions until applications are thoroughly tested. */

#define NCL_DCSUBMATRIX_SIZE NCL_SUBMATRIX_SIZE
typedef int ncl_dchidden_submatrix[NCL_DCSUBMATRIX_SIZE/sizeof(int)];

typedef struct { /* submatrix class definition */
/* private: */
ncl_dchidden_submatrix M;
} ncl_dcsubmatrix;
/* A submatrix does not own the array storage that it references. */
/* It does not allocate any array storage when it is constructed */
/* nor does it deallocate any array storage when it is destroyed. */

#endif /* NCL_REVEAL */

inline static
ncl_dcsubmatrix /* automatic storage constructor */
(ncl_dcsubm_create)(
ncl_dchandle h, ncl_offset o,
ncl_extent m, ncl_stride s2,
ncl_extent n, ncl_stride s1) {
ncl_dcsubmatrix M;
ncl_dcsubm_init(&M, h, o, m, s2, n, s1);
return M; }

inline static
void /* automatic storage destructor */
(ncl_dcsubm_destroy)(ncl_dcsubmatrix* pM) {
pM->_ = ~ncl_other; }

inline static
ncl_dcsubmatrix* /* free storage constructor */
(ncl_dcsubm_new)(
ncl_dchandle h, ncl_offset o,
ncl_extent m, ncl_stride s2,
ncl_extent n, ncl_stride s1) {
ncl_dcsubmatrix* pM
= (ncl_dcsubmatrix*)malloc(sizeof(ncl_dcsubmatrix));
if (pM)
ncl_dcsubm_init(pM, h, o, m, s2, n, s1);
return pM; }

inline static
void /* free storage destructor */
(ncl_dcsubm_delete)(ncl_dcsubmatrix* pM) {
ncl_dcsubm_destroy(pM);
free((void*)pM); }

Nov 13 '05 #12
On Fri, 12 Sep 2003 22:40:33 +0200, "Serve La" <ik@veranderhetal.com>
wrote in comp.lang.c:
When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that dynamically
allocate/free the struct and then I create a bunch of functions that operate
on the struct. Example:

typedef struct ccHashTab
{
....
} ccHashTab;


One style comment. I personally don't like the practice of using a
struct tag and a typedef for the same structure. One or the other,
please, but not both.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Nov 13 '05 #13
Jack Klein wrote:
Serve La wrote:
When I write a medium to large sized C application,
I tend to create structures first then makeStruct and freeStruct
functions that dynamically allocate/free the struct and then
I create a bunch of functions that operate on the struct. Example:

typedef struct ccHashTab {
// ...
} ccHashTab;


One style comment.
I personally don't like the practice
of using a struct tag and a typedef for the same structure.
One or the other, please, but not both.


Can you give us a clue why you don't like it?

Nov 13 '05 #14
Jack Klein wrote:
On Fri, 12 Sep 2003 22:40:33 +0200, "Serve La" <ik@veranderhetal.com>
wrote in comp.lang.c:
When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that
dynamically allocate/free the struct and then I create a bunch of
functions that operate on the struct. Example:

typedef struct ccHashTab
{
....
} ccHashTab;


One style comment. I personally don't like the practice of using a
struct tag and a typedef for the same structure. One or the other,
please, but not both.


Hmmm, disagreeing with Jack Klein for a second consecutive article. This is
getting worrying.

Jack -- as you say, it's a style point. I use structure tags for all structs
nowadays, partly in the usual cluon economy drive, so that I don't have to
remember when I need a tag and when I don't, but also to reduce by a tiny
amount the maintenance work involved in making a struct self-referential,
at the expense of a slightly larger amount of work up front!

On the other hand, I like typedefs. Again, I use them for all structs
nowadays. I like the idea of being able to abstract away the structness of
a struct. I am of the opinion that it makes my programs more pleasant to
read, for many people at least, and perhaps even for most people.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #15

"Malcolm" <ma*****@55bank.freeserve.co.uk> wrote in message
news:bk**********@newsg4.svr.pol.co.uk...

"Serve La" <ik@veranderhetal.com> wrote in message
Of course the burning question, then is, why not use C++ instead of >

C then?

Huh?
Because OO is not bound to C++

C++ classes are only really useful when you have inheritance relationships
between them. If you are not going to base your design on a class

hierarchy, a C implementation will generally be cleaner and easier to understand and
maintain.


I agree with that and I'll even add inheriting to the list. Only if you want
to override functions then C is not easy to use anymore. Handling virtual
function tables yourself is not easy and maintainable anymore.
Nov 13 '05 #16

"Jack Klein" <ja*******@spamcop.net> wrote in message
news:im********************************@4ax.com...
typedef struct ccHashTab
{
....
} ccHashTab;


One style comment. I personally don't like the practice of using a
struct tag and a typedef for the same structure. One or the other,
please, but not both.


I was expecting that somebody would say that :)
But I have chosen this style because I don't see any problems with it only
advantages.

Why was C designed this way? That you have to declare a struct as a struct,
enum as an enum.....
Nov 13 '05 #17
On Fri, 12 Sep 2003 20:40:33 UTC, "Serve La" <ik@veranderhetal.com>
wrote:
When I write a medium to large sized C application I tend to create
structures first, then makeStruct and freeStruct functions that dynamically
allocate/free the struct and then I create a bunch of functions that operate
on the struct. Example:


That's the way I work since the first days of programming I've ever
done (and that was long before C were existent.
With C there is more help to encapsulate things. Think OO, but write
procedual.

1. a header file that holds the external interfaces.
- an abstract type name
- function prototypes
2.. a translation unit that holds the data descriptions and the
functions used to get anything done.

--
Tschau/Bye
Herbert

eComStation 1.1 Deutsch Beta ist verügbar
Nov 13 '05 #18

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:3F**************@jpl.nasa.gov...
typedef struct { /* submatrix class definition */
/* private: */
ncl_dchandle H;
ncl_offset O;
ncl_extent N1;
ncl_stride S1;
ncl_extent N2;
ncl_stride S2;
ncl_______ _;
} ncl_dcsubmatrix;


Ah, ok, but this struct has only valuetypes that can be easily copied. What
you said was "It works well no matter how complicated the data structure"
What if a struct contains pointers or other structs that contain pointers?
Nov 13 '05 #19

On Sun, 14 Sep 2003, Serve La wrote:

"Jack Klein" <ja*******@spamcop.net> wrote...
typedef struct ccHashTab
{
....
} ccHashTab;
One style comment. I personally don't like the practice of using a
struct tag and a typedef for the same structure. One or the other,
please, but not both.


I was expecting that somebody would say that :)
But I have chosen this style because I don't see any problems
with it only advantages.


(Personally, I don't often use typedefs. But in the rare case I do,
I try to give the struct tag and the typedef-name *different*
identifiers; perhaps 'typedef struct Foo_tag { } Foo;', for example.
It's less confusing than having the same identifier mean different
things in different namespaces, IMHO.)

Why was C designed this way? That you have to declare a struct
as a struct, enum as an enum.....


I do believe you've just answered your own question. :)

-Arthur

Nov 13 '05 #20
Serve La wrote:
E. Robert Tisdale wrote:
typedef struct { /* submatrix class definition */
/* private: */
ncl_dchandle H;
ncl_offset O;
ncl_extent N1;
ncl_stride S1;
ncl_extent N2;
ncl_stride S2;
ncl_______ _;
} ncl_dcsubmatrix;

Ah, ok, but this struct has only valuetypes that can be easily copied. What
you said was "It works well no matter how complicated the data structure"
What if a struct contains pointers or other structs that contain pointers?


You mean like the ncl_dchandle member in the ncl_dcsubmatrix object?

Please take the time to download and study the CNCL.
I will be happy to answer any questions that you may have about it.
Nov 13 '05 #21
Malcolm wrote:
C++ classes are only really useful
when you have inheritance relationships between them.
If you are not going to base your design on a class hierarchy,
a C implementation will generally be cleaner
and easier to understand and maintain.


No.

C++ classes allow you to "hide" the actual data representation
by labeling the data members private:
You would need to use "opaque" types in C
to hide data members effectively.
Unfortunately, opaque data types preclude the use of
inline functions or even C preprocessor macros
to access private data members efficiently.

Nov 13 '05 #22
The Real OS/2 Guy wrote:
With C there is more help to encapsulate things.
Think OO, but write procedural.

1. a header file that holds the external interfaces.
- an [opaque] type name
- function [declarations]
2.. a translation unit that holds the data descriptions
and the functions [definitions] used to get anything done.


The problem with opaque types is that the methods cannot be
implemented as inline functions of C preprocessor macros.
This virtually precludes the use of opaque types
in many high performance applications.

Nov 13 '05 #23
On 13 Sep 2003 06:54:42 -0700, qe*@pobox.com (Paul Hsieh) wrote:
"Serve La" <ik@veranderhetal.com> wrote: <snip>
typedef struct ccHashTab
{
....
} ccHashTab;


This typedef is unnecessary and doesn't really do anything useful,
except confuse C++ people (in C++ struct ___ doesn't create a new name
space, the "struct" can be dropped.)

This isn't quite true. In C++ a (struct, class, union, or enum) tag
can be used alone as a type name, *if* the same name is not declared
in the same (or inner) scope as an ordinary identifier; in the latter
case, you must use an elaborated-type-specifier, that is the keyword
struct, class, union or enum plus the tag, just as you always do in C.

And to be clear this is only on references; the keyword is always
required on the declaration of the struct etc. itself.

<snip> I do it this way:

/* constructor/destructor */
struct ccHashTab * newCcHash (unsigned int size, int (* keyFn)(void
*));
int destroyCcHash (struct ccHashTab *table);

int clearCcHash (struct ccHashTab *table);
int iterateCcHash (struct ccHashTab *table,
int (* cb) (void * ctx, void * entry), void * ctx);
int insertCcHash (struct ccHashTab *table, void * entry);
int deleteCcHash (struct ccHashTab *table, void * entry);
void * findCcHash (struct ccHashTab *table, void * entry);
/* and other "methods" */

is put in hash.h, and the struct ccHashTab definition is only in the
hash module. Knowing that its a pointer to a struct doesn't really
ruin its opaqueness, if you don't know the structure contents.
However, it makes it clear that you cannot copy it without a copy
method.
Are you relying on a convention that the ctor is declared first, and
uses the struct tag in its return type, to avoid problems with the tag
being "confined" to prototype scope? I think I would put in a "struct
ccHashTab /*opaque*/ ;" to be more robust, and IMVHO clearer.
One of the things that's always bothered me is that I cannot put
"const" on the table declaration in the findCcHash function. The
reason is that you are returning a pointer that table is pointing to,
and thus the compiler cannot figure out whether or not you might
modify its contents.

I don't follow this. You mean you are returning a pointer *value*
stored, by a previous insert_, in the table? That should work fine
for a const tabtype * table, even if the contained and returned
pointer is not to const. (Even in C++, which allows adding const
"further away" than C does, but not the reverse of restricting
removing them.) Can you be more specific about the problem?

- David.Thompson1 at worldnet.att.net
Nov 13 '05 #24

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

Similar topics

12
by: David MacQuigg | last post by:
I have what looks like a bug trying to generate new style classes with a factory function. class Animal(object): pass class Mammal(Animal): pass def newAnimal(bases=(Animal,), dict={}):...
15
by: Christopher Benson-Manica | last post by:
If you had an unsigned int that needed to be cast to a const myClass*, would you use const myClass* a=reinterpret_cast<const myClass*>(my_val); or const myClass* a=(const myClass*)myVal; ...
33
by: amerar | last post by:
Hi All, I can make a page using a style sheet, no problem there. However, if I make an email and send it out to my list, Yahoo & Hotmail totally ignore the style tags. It looks fine in...
1
by: amerar | last post by:
Hi All, I posted a question about style sheets, and why certain email clients were ignoring them. Someone suggested placing them inline. I did this and get better results, but not what I...
4
by: KvS | last post by:
Hi all, I'm pretty new to (wx)Python so plz. don't shoot me if I've missed something obvious ;). I have a panel inside a frame, on which a Button and a StaticText is placed: self.panel =...
83
by: rahul8143 | last post by:
hello, what is difference between sizeof("abcd") and strlen("abcd")? why both functions gives different output when applied to same string "abcd". I tried following example for that. #include...
39
by: jamilur_rahman | last post by:
What is the BIG difference between checking the "if(expression)" in A and B ? I'm used to with style A, "if(0==a)", but my peer reviewer likes style B, how can I defend myself to stay with style A...
18
by: pocmatos | last post by:
Hi all, While I was programming 5 minutes ago a recurring issue came up and this time I'd like to hear some opinions on style. Although they are usually personal I do think that in this case as...
3
Claus Mygind
by: Claus Mygind | last post by:
I want to move some style setting into a javaScript function so I can make them variable but I get "invalid assignment left-hand side" error? see my question at the bottom of this message. It...
6
by: MatthewS | last post by:
I've seen the question raised several times here, but apparently never answered. Since PyInstance_Check returns False for new-style class instances, is there a standard procedure for testing this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.