concatenation

L

Laszlo

Hi all

I my A C++ class at a point I declared a
char *toString()
method. My class A, I have some private
members like
float l, h;
char *name
wich are initialized by the constructor:
l = 10.0;
h = 15.8;
name = "THE_NAME";

When I invoke the toString method, I would
like to get a result like this:

NAME[THE_NAME]:LENGTH[10.0]:HEIGHT[15.8]

How should I write the toString method?
Thank you.

Laci
 
F

Flash Gordon

Laszlo said:
Hi all

I my A C++ class at a point I declared a

<snip>

In your C++ class did they tell you that C and C++ are different languages?

I suggest you go down the hall to comp.lang.c++ where they discuss C++
since here we only discuss C.
 
J

Jens.Toerring

Laszlo said:
I my A C++ class at a point I declared a
char *toString()
method. My class A, I have some private

Sorry, but stop right here. You unfortunately picked the wrong
newsgroup, this one is about C and not C++. Please post this in
comp.lang.c++ where you will find the experts for C++.

Regards, Jens
 
T

Thomas Matthews

Laszlo said:
Hi all

I my A C++ class at a point I declared a
char *toString()
method. My class A, I have some private
members like
float l, h;
char *name
wich are initialized by the constructor:
l = 10.0;
h = 15.8;
name = "THE_NAME";

When I invoke the toString method, I would
like to get a result like this:

NAME[THE_NAME]:LENGTH[10.0]:HEIGHT[15.8]

How should I write the toString method?
Thank you.

Laci

I believe you have the wrong newsgroup,
as there are no "classes" in the C language.
[See the std::string class.]

Try using sprintf().


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,888
Members
47,420
Latest member
ZitaVos505

Latest Threads

Top