Re: [Dev-C++] What's the difference?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <or...@vp...> - 2003-03-04 15:20:10
|
Ioannis Vranos wrote:
> ==> ? In fact allocating/releasing space on the free store is more
> time-expensive than using local space in the stack.
It is, but using the stack is only advisable for temporary structures.
> How i would do it:
>
> #include <string>
>
> struct foo
> {
> std::string text1, text2, text3;
>
> foo(const std::string &t1, const std::string &t2, const std::string &t3):
> text1(t1), text2(t2), text3(t3) { }
>
> };
>
> void whatever(foo &);
> int main()
> {
> foo something("telos", "ton", "imeron");
> whatever(something);
> }
>
> void whatever(foo &pf)
> {
> // ...
> }
>
> ==> Or even better i would provide it as a class with access functions.
Well yes, I see now. I don't know C++, so I looked up in a book what you
wrote, and it seems you use references. Isn't that the same as using
pointers?
Anyway, in C, pointers are the only way.
--
Greetings,
Balázs
|