473,326 Members | 2,147 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,326 software developers and data experts.

How do I put this statement in the class definition

Hello!!

I have these two statements
"typedef const char *enum_txt[];"
"enum_txt phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};"

It's no problem to put the first statement "typedef const char *enum_txt[];"
for example the public section.in the definition of the class but how do I
put
this statement "enum_txt phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};"
is the class definition because when I do I get compile error.

//Tony

Jul 22 '05 #1
3 2076
Tony Johansson wrote:
Hello!!

I have these two statements
"typedef const char *enum_txt[];"
"enum_txt phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};"

It's no problem to put the first statement "typedef const char *enum_txt[];"
for example the public section.in the definition of the class but how do I
put
this statement "enum_txt phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};"
is the class definition because when I do I get compile error.

//Tony

Declare them as static member of the class and define while initializing
it outside the class definition.
Jul 22 '05 #2

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:2p*********************@newsc.telia.net...
Hello!!

I have these two statements
"typedef const char *enum_txt[];"
"enum_txt phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};"

It's no problem to put the first statement "typedef const char
*enum_txt[];" for example the public section.in the definition of the
class but how do I put
this statement "enum_txt phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};"
is the class definition because when I do I get compile error.

//Tony


You can't but you don't need to.

I guess you're looking for something like this

class X
{
public:
static const char* const phase_tab[];
};

const char* const X::phase_tab[] =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};

No typedef necessary.

john
Jul 22 '05 #3
John Harrison wrote:
"Tony Johansson" <jo*****************@telia.com> wrote in message
I have these two statements
"typedef const char *enum_txt[];"
"enum_txt phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTE RRELEASE","SPACE"};"


You can't but you don't need to.

I guess you're looking for something like this

class X
{
public:
static const char* const phase_tab[];
};

const char* const X::phase_tab[] =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};

No typedef necessary.

john


Oh i see, i didn't notice the typedef is for the definition. Then
actually he can just write

I guess you're looking for something like this

class X
{
public:
static const char* const phase_tab[];
};

typedef const char *enum_txt[];
enum_txt X::phase_tab =
{"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERR ELEASE","SPACE"};

which is more readable
Jul 22 '05 #4

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

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
94
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
67
by: Rui Maciel | last post by:
I've been delving into finite state machines and at this time it seems that the best way to implement them is through an intense use of the goto statement. Yet, everyone plus their granmother is...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
2
by: Danny Shevitz | last post by:
Howdy, In my app I need to exec user text that defines a function. I want this function to unpickle an object. Pickle breaks because it is looking for the object definition that isn't in the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.